Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / TypeGenericEnumerableViewSchema.cs / 2 / TypeGenericEnumerableViewSchema.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design { using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; ////// Represents a View's schema based on a generic IEnumerable. The /// strongly-typed row type is determined based on the generic argument /// of the enumerable. /// [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)] internal sealed class TypeGenericEnumerableViewSchema : BaseTypeViewSchema { public TypeGenericEnumerableViewSchema(string viewName, Type type) : base(viewName, type) { Debug.Assert(TypeSchema.IsBoundGenericEnumerable(type), String.Format(CultureInfo.InvariantCulture, "The type '{0}' does not implement System.Collections.Generic.IEnumerable, or the argument T is not bound to a type.", type.FullName)); } protected override Type GetRowType(Type objectType) { // Get the IEnumerable declaration Type enumerableType = null; if (objectType.IsInterface && objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof(IEnumerable<>)) { // If the type already is IEnumerable , that's the interface we want to inspect enumerableType = objectType; } else { // Otherwise we get a list of all the interafaces the type implements Type[] interfaces = objectType.GetInterfaces(); foreach (Type i in interfaces) { if (i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable<>)) { enumerableType = i; break; } } } Debug.Assert(enumerableType != null, "Should have found an implementation of IEnumerable "); // Now return the value of the T argument Type[] genericArguments = enumerableType.GetGenericArguments(); Debug.Assert(genericArguments != null && genericArguments.Length == 1, "Expected IEnumerable to have a generic argument"); // If a type has IsGenericParameter=true that means it is not bound. if (genericArguments[0].IsGenericParameter) { Debug.Fail("Expected the type argument to IEnumerable to be bound"); return null; } else { return genericArguments[0]; } } } } // 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
- DbMetaDataFactory.cs
- DataGridHeaderBorder.cs
- UpWmlPageAdapter.cs
- Control.cs
- IgnoreSectionHandler.cs
- ReflectionHelper.cs
- PrintController.cs
- TabControlEvent.cs
- SqlUtil.cs
- XPathSelectionIterator.cs
- DataSourceGroupCollection.cs
- BuildDependencySet.cs
- SerializeAbsoluteContext.cs
- XmlDesigner.cs
- EventListener.cs
- ObfuscateAssemblyAttribute.cs
- DataGridPagerStyle.cs
- TextEditorParagraphs.cs
- BaseCollection.cs
- ToolStripTextBox.cs
- SessionStateItemCollection.cs
- Control.cs
- ISessionStateStore.cs
- EntityDataSourceSelectedEventArgs.cs
- GridViewRowEventArgs.cs
- HttpListenerResponse.cs
- GeometryHitTestParameters.cs
- HostedImpersonationContext.cs
- IndexedSelectQueryOperator.cs
- SqlCacheDependency.cs
- CopyAttributesAction.cs
- DataGridViewColumnCollectionEditor.cs
- DiagnosticTrace.cs
- CryptoApi.cs
- xmlsaver.cs
- SpellCheck.cs
- DecimalConverter.cs
- CacheRequest.cs
- ParseChildrenAsPropertiesAttribute.cs
- WebControl.cs
- _IPv4Address.cs
- FrameworkElementFactory.cs
- XmlCharCheckingReader.cs
- SafeThemeHandle.cs
- RichTextBoxDesigner.cs
- RouteValueDictionary.cs
- ImageCollectionEditor.cs
- Metadata.cs
- clipboard.cs
- UidPropertyAttribute.cs
- XsltSettings.cs
- PriorityRange.cs
- SmiXetterAccessMap.cs
- NetworkInformationException.cs
- MatrixValueSerializer.cs
- SafeRightsManagementHandle.cs
- XmlUtil.cs
- Renderer.cs
- GridViewEditEventArgs.cs
- SerialStream.cs
- Compress.cs
- SuppressIldasmAttribute.cs
- ScriptManagerProxy.cs
- MissingSatelliteAssemblyException.cs
- PersonalizableAttribute.cs
- EditorZone.cs
- RolePrincipal.cs
- RectAnimation.cs
- DisplayNameAttribute.cs
- BasePattern.cs
- HTTPNotFoundHandler.cs
- CodeLinePragma.cs
- CompModSwitches.cs
- DefaultSerializationProviderAttribute.cs
- SafeHandles.cs
- AttributeEmitter.cs
- ArrayList.cs
- TransformGroup.cs
- InstanceNormalEvent.cs
- MaterialCollection.cs
- ProxyWebPart.cs
- ExpressionQuoter.cs
- PenCursorManager.cs
- AnnotationStore.cs
- TransactionChannelListener.cs
- DynamicQueryableWrapper.cs
- Cast.cs
- Point3DAnimationUsingKeyFrames.cs
- NullableLongAverageAggregationOperator.cs
- StateBag.cs
- PolyLineSegment.cs
- HttpRequestCacheValidator.cs
- MulticastNotSupportedException.cs
- MetadataFile.cs
- VectorAnimationBase.cs
- DropShadowEffect.cs
- DebugTrace.cs
- PrintDialog.cs
- TypeBuilderInstantiation.cs
- BindingContext.cs