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
- DependencyPropertyChangedEventArgs.cs
- UseLicense.cs
- PagesSection.cs
- DelegateSerializationHolder.cs
- TextEffectResolver.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- InlineCollection.cs
- PathGeometry.cs
- COSERVERINFO.cs
- ScaleTransform3D.cs
- ExtractorMetadata.cs
- DateTimeOffsetAdapter.cs
- PagePropertiesChangingEventArgs.cs
- MarshalByRefObject.cs
- UnauthorizedAccessException.cs
- CompilerCollection.cs
- Form.cs
- SupportsPreviewControlAttribute.cs
- CompiledELinqQueryState.cs
- SettingsPropertyNotFoundException.cs
- FamilyMapCollection.cs
- HighContrastHelper.cs
- BitmapDownload.cs
- Matrix.cs
- DataRecord.cs
- HashAlgorithm.cs
- Window.cs
- ExceptionTrace.cs
- messageonlyhwndwrapper.cs
- SqlDataSourceFilteringEventArgs.cs
- SqlConnectionStringBuilder.cs
- _DigestClient.cs
- LinqDataSource.cs
- DiscoveryCallbackBehavior.cs
- ViewManager.cs
- HttpInputStream.cs
- UserValidatedEventArgs.cs
- XamlStackWriter.cs
- UpdateCommandGenerator.cs
- BrowserDefinition.cs
- EntityStoreSchemaGenerator.cs
- CqlLexerHelpers.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- DataGridViewCellParsingEventArgs.cs
- RootProfilePropertySettingsCollection.cs
- EventArgs.cs
- RenderTargetBitmap.cs
- DetailsViewUpdateEventArgs.cs
- WebException.cs
- SamlAuthenticationStatement.cs
- RoleService.cs
- CreationContext.cs
- ApplicationException.cs
- EntityViewGenerationConstants.cs
- MenuTracker.cs
- XmlIgnoreAttribute.cs
- DocumentStream.cs
- TypeSchema.cs
- SuppressIldasmAttribute.cs
- DependencyObject.cs
- WmlListAdapter.cs
- Identifier.cs
- ResourceProviderFactory.cs
- FixedSOMPage.cs
- StandardTransformFactory.cs
- SqlMethods.cs
- ElementHost.cs
- OrCondition.cs
- ProtocolsConfiguration.cs
- SQLDecimalStorage.cs
- WebBrowserDocumentCompletedEventHandler.cs
- KeyedHashAlgorithm.cs
- DataGridCell.cs
- UncommonField.cs
- TaskExtensions.cs
- ProgressBarAutomationPeer.cs
- DataObject.cs
- GeometryConverter.cs
- NativeMethods.cs
- NetTcpSectionData.cs
- TableStyle.cs
- WebConfigurationFileMap.cs
- CounterCreationDataCollection.cs
- UiaCoreTypesApi.cs
- XmlText.cs
- GuidelineSet.cs
- VisualProxy.cs
- XmlSerializationReader.cs
- SafeFindHandle.cs
- Int32.cs
- FrameDimension.cs
- DataServiceStreamProviderWrapper.cs
- XsdDateTime.cs
- XmlBindingWorker.cs
- WmfPlaceableFileHeader.cs
- ListParagraph.cs
- ClientUrlResolverWrapper.cs
- TreeViewBindingsEditor.cs
- DataAdapter.cs
- HandlerFactoryWrapper.cs