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
- X509Utils.cs
- QilInvokeEarlyBound.cs
- XmlJsonWriter.cs
- XsltOutput.cs
- SchemaElementDecl.cs
- OleDbErrorCollection.cs
- ProvidersHelper.cs
- JpegBitmapDecoder.cs
- ByValueEqualityComparer.cs
- MissingFieldException.cs
- ExpressionValueEditor.cs
- CodeArgumentReferenceExpression.cs
- IndexerHelper.cs
- OverloadGroupAttribute.cs
- EntityDataSourceView.cs
- controlskin.cs
- PolyLineSegmentFigureLogic.cs
- Encoder.cs
- columnmapfactory.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- XmlILOptimizerVisitor.cs
- StyleSheetRefUrlEditor.cs
- UrlPath.cs
- TransformProviderWrapper.cs
- DataListItem.cs
- DataBoundControl.cs
- Activator.cs
- MultiPartWriter.cs
- SqlExpander.cs
- InsufficientMemoryException.cs
- ObjectStateManager.cs
- ApplicationServiceHelper.cs
- validation.cs
- SqlExpressionNullability.cs
- LocatorPart.cs
- BackgroundFormatInfo.cs
- XmlSchemaDocumentation.cs
- FileInfo.cs
- CompiledELinqQueryState.cs
- SourceElementsCollection.cs
- OdbcConnectionHandle.cs
- TextParagraphProperties.cs
- UnsafeNativeMethods.cs
- DoubleAnimationClockResource.cs
- SqlProfileProvider.cs
- DispatchChannelSink.cs
- shaperfactory.cs
- DPTypeDescriptorContext.cs
- COM2ComponentEditor.cs
- SymbolEqualComparer.cs
- TargetConverter.cs
- PeerInvitationResponse.cs
- DataService.cs
- Bind.cs
- ArrayExtension.cs
- ButtonFlatAdapter.cs
- TaskHelper.cs
- ButtonFieldBase.cs
- SiteMap.cs
- LicenseProviderAttribute.cs
- DataGridViewHeaderCell.cs
- CodeDelegateCreateExpression.cs
- _AutoWebProxyScriptWrapper.cs
- ConfigXmlAttribute.cs
- _Win32.cs
- AvTraceFormat.cs
- RefreshResponseInfo.cs
- tooltip.cs
- DataGridViewCellLinkedList.cs
- RadioButtonRenderer.cs
- ContainsRowNumberChecker.cs
- CustomMenuItemCollection.cs
- ManagedIStream.cs
- DesignerTransaction.cs
- ConfigurationStrings.cs
- GradientSpreadMethodValidation.cs
- GradientBrush.cs
- EventMappingSettings.cs
- GlobalEventManager.cs
- ArrangedElement.cs
- Light.cs
- ZoneIdentityPermission.cs
- TemplateLookupAction.cs
- SqlSupersetValidator.cs
- GridToolTip.cs
- ColumnCollection.cs
- RsaKeyIdentifierClause.cs
- PersonalizationAdministration.cs
- OrthographicCamera.cs
- Stream.cs
- ResourcesBuildProvider.cs
- WSHttpTransportSecurityElement.cs
- XmlAttributeAttribute.cs
- AsymmetricAlgorithm.cs
- FamilyMapCollection.cs
- HtmlInputReset.cs
- ZipFileInfo.cs
- TrailingSpaceComparer.cs
- WsatConfiguration.cs
- RegexTree.cs