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
- HwndSource.cs
- DataGridItem.cs
- CommandField.cs
- LayoutSettings.cs
- ThousandthOfEmRealDoubles.cs
- StreamWriter.cs
- UriSection.cs
- BindingListCollectionView.cs
- HeaderCollection.cs
- SemaphoreFullException.cs
- WebPartConnectionsCancelVerb.cs
- GenericPrincipal.cs
- _emptywebproxy.cs
- Padding.cs
- RepeaterItem.cs
- SmtpCommands.cs
- TextTreeUndoUnit.cs
- DoubleConverter.cs
- FontClient.cs
- DataGridViewCellFormattingEventArgs.cs
- Brush.cs
- BamlLocalizableResource.cs
- IndexingContentUnit.cs
- AutomationIdentifier.cs
- TileBrush.cs
- XmlDeclaration.cs
- CombinedGeometry.cs
- DependencyObject.cs
- NegotiateStream.cs
- RayHitTestParameters.cs
- AspNetSynchronizationContext.cs
- CanExecuteRoutedEventArgs.cs
- GridViewSortEventArgs.cs
- WorkflowMarkupSerializationManager.cs
- CompilationRelaxations.cs
- SchemaAttDef.cs
- LicenseManager.cs
- SafeFileHandle.cs
- ReturnEventArgs.cs
- Encoding.cs
- DataServiceExpressionVisitor.cs
- CryptoProvider.cs
- Pair.cs
- _NegotiateClient.cs
- PreservationFileWriter.cs
- ManagementClass.cs
- TextEvent.cs
- ContainsRowNumberChecker.cs
- XmlCodeExporter.cs
- ListBox.cs
- Process.cs
- ContextStaticAttribute.cs
- ModuleConfigurationInfo.cs
- WinFormsSecurity.cs
- SqlEnums.cs
- EmptyEnumerator.cs
- Command.cs
- DataGridColumnCollection.cs
- DesignerTransactionCloseEvent.cs
- XmlEntityReference.cs
- ObjectTag.cs
- ApplicationGesture.cs
- Matrix.cs
- DbConnectionPoolOptions.cs
- SecureStringHasher.cs
- NativeMethods.cs
- ToolStripContentPanelRenderEventArgs.cs
- SHA384Managed.cs
- PageRanges.cs
- Propagator.ExtentPlaceholderCreator.cs
- HtmlLink.cs
- SatelliteContractVersionAttribute.cs
- EntityConnectionStringBuilder.cs
- DataGridViewTopLeftHeaderCell.cs
- Types.cs
- Vector3DKeyFrameCollection.cs
- M3DUtil.cs
- TargetInvocationException.cs
- TextureBrush.cs
- ActivityCodeGenerator.cs
- CapabilitiesSection.cs
- Pen.cs
- InfiniteIntConverter.cs
- Comparer.cs
- PieceDirectory.cs
- LicenseContext.cs
- LongSumAggregationOperator.cs
- WhitespaceRuleReader.cs
- SocketAddress.cs
- OracleConnectionFactory.cs
- InstanceStoreQueryResult.cs
- OdbcPermission.cs
- HttpModuleActionCollection.cs
- ValueSerializer.cs
- ResourceDescriptionAttribute.cs
- SeekableReadStream.cs
- AssociationSet.cs
- HtmlImage.cs
- DeferrableContent.cs
- EDesignUtil.cs