Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / TypeHelper.cs / 1305376 / TypeHelper.cs
using System; using System.Collections.Generic; using System.Text; namespace System.Linq { internal static class TypeHelper { internal static bool IsEnumerableType(Type enumerableType) { return FindGenericType(typeof(IEnumerable<>), enumerableType) != null; } internal static bool IsKindOfGeneric(Type type, Type definition) { return FindGenericType(definition, type) != null; } internal static Type GetElementType(Type enumerableType) { Type ienumType = FindGenericType(typeof(IEnumerable<>), enumerableType); if (ienumType != null) return ienumType.GetGenericArguments()[0]; return enumerableType; } internal static Type FindGenericType(Type definition, Type type) { while (type != null && type != typeof(object)) { if (type.IsGenericType && type.GetGenericTypeDefinition() == definition) return type; if (definition.IsInterface) { foreach(Type itype in type.GetInterfaces()) { Type found = FindGenericType(definition, itype); if (found != null) return found; } } type = type.BaseType; } return null; } internal static bool IsNullableType(Type type) { return type != null && type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); } internal static Type GetNonNullableType(Type type) { if (IsNullableType(type)) { return type.GetGenericArguments()[0]; } return type; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LayoutUtils.cs
- infer.cs
- TableCellCollection.cs
- ClockController.cs
- CryptographicAttribute.cs
- TransformGroup.cs
- SymbolMethod.cs
- TypeConverters.cs
- SystemThemeKey.cs
- EventEntry.cs
- SqlServer2KCompatibilityAnnotation.cs
- ComponentResourceKeyConverter.cs
- XmlSchemaAnnotated.cs
- IFormattable.cs
- PenContexts.cs
- TextEditorContextMenu.cs
- NativeWindow.cs
- Drawing.cs
- LinkedResourceCollection.cs
- OleDbFactory.cs
- QueryCorrelationInitializer.cs
- TdsRecordBufferSetter.cs
- WrappedIUnknown.cs
- AsyncCompletedEventArgs.cs
- AttributeQuery.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- DelegateBodyWriter.cs
- SynchronizedMessageSource.cs
- COM2FontConverter.cs
- UmAlQuraCalendar.cs
- FileCodeGroup.cs
- XmlNodeChangedEventArgs.cs
- updatecommandorderer.cs
- ObjectFullSpanRewriter.cs
- ChtmlTextWriter.cs
- MdImport.cs
- PermissionListSet.cs
- entitydatasourceentitysetnameconverter.cs
- ReadContentAsBinaryHelper.cs
- DataControlLinkButton.cs
- XamlReaderHelper.cs
- XsltSettings.cs
- BevelBitmapEffect.cs
- XmlSerializerFactory.cs
- ServiceDescriptionReflector.cs
- TimeSpanFormat.cs
- CodeMemberMethod.cs
- FileDialog_Vista_Interop.cs
- XmlSchemaSet.cs
- ToolStripGripRenderEventArgs.cs
- SiteMap.cs
- NetCodeGroup.cs
- TagPrefixInfo.cs
- PropertyDescriptor.cs
- SafeSecurityHandles.cs
- Int32Rect.cs
- RunInstallerAttribute.cs
- DynamicResourceExtensionConverter.cs
- SchemaEntity.cs
- DefinitionBase.cs
- AuthenticatedStream.cs
- HttpHeaderCollection.cs
- ConnectionConsumerAttribute.cs
- StrokeNodeEnumerator.cs
- PointCollection.cs
- NativeMethods.cs
- ToolStripDropDownMenu.cs
- StorageSetMapping.cs
- ThreadStartException.cs
- NumberAction.cs
- CheckedListBox.cs
- ClientRoleProvider.cs
- ApplicationBuildProvider.cs
- HWStack.cs
- x509utils.cs
- XmlSchemaComplexContent.cs
- Clipboard.cs
- PeerNameResolver.cs
- ColumnTypeConverter.cs
- WorkflowServiceBehavior.cs
- OutputCacheModule.cs
- MultiView.cs
- CompletionCallbackWrapper.cs
- GeneralTransform2DTo3DTo2D.cs
- TokenBasedSet.cs
- OpenFileDialog.cs
- TextOnlyOutput.cs
- ConfigurationSectionHelper.cs
- SHA1Managed.cs
- ContainerUtilities.cs
- UrlPropertyAttribute.cs
- CommentAction.cs
- SystemResourceKey.cs
- EncoderFallback.cs
- CompensateDesigner.cs
- ObjectHelper.cs
- IDReferencePropertyAttribute.cs
- UIAgentAsyncParams.cs
- DataReaderContainer.cs
- MasterPageCodeDomTreeGenerator.cs