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
- WebHttpBindingCollectionElement.cs
- PlatformNotSupportedException.cs
- IndicFontClient.cs
- CapabilitiesPattern.cs
- StyleModeStack.cs
- CriticalExceptions.cs
- TreeViewHitTestInfo.cs
- ConfigXmlComment.cs
- NullNotAllowedCollection.cs
- SimpleTypesSurrogate.cs
- BinaryConverter.cs
- NamedPipeAppDomainProtocolHandler.cs
- M3DUtil.cs
- AddInStore.cs
- DefaultWorkflowLoaderService.cs
- EntityDescriptor.cs
- FactoryRecord.cs
- UmAlQuraCalendar.cs
- XmlWhitespace.cs
- NoneExcludedImageIndexConverter.cs
- ContainerFilterService.cs
- StaticSiteMapProvider.cs
- TableLayoutSettings.cs
- DrawingVisualDrawingContext.cs
- PlatformNotSupportedException.cs
- httpapplicationstate.cs
- ListControl.cs
- SerialStream.cs
- XmlSchemaRedefine.cs
- GC.cs
- WebServiceHost.cs
- CharEnumerator.cs
- FileChangesMonitor.cs
- MasterPageParser.cs
- updatecommandorderer.cs
- ConnectionStringSettingsCollection.cs
- FrameworkEventSource.cs
- TextContainerHelper.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- MultiView.cs
- _KerberosClient.cs
- ListBoxItemAutomationPeer.cs
- TrayIconDesigner.cs
- LoadedEvent.cs
- CapabilitiesPattern.cs
- RegexFCD.cs
- ContentWrapperAttribute.cs
- LocalIdKeyIdentifierClause.cs
- RunClient.cs
- DeflateInput.cs
- ServiceNameElement.cs
- Int64.cs
- ImageListUtils.cs
- WindowsButton.cs
- DispatcherExceptionFilterEventArgs.cs
- ProgramNode.cs
- GridViewDesigner.cs
- _BaseOverlappedAsyncResult.cs
- exports.cs
- Encoder.cs
- AspNetSynchronizationContext.cs
- ReferentialConstraint.cs
- HiddenFieldPageStatePersister.cs
- SoapIncludeAttribute.cs
- WindowsSspiNegotiation.cs
- DataAdapter.cs
- NameGenerator.cs
- StringConcat.cs
- HtmlContainerControl.cs
- NavigationPropertySingletonExpression.cs
- CategoryAttribute.cs
- WebBrowserPermission.cs
- CssTextWriter.cs
- DecimalAnimationUsingKeyFrames.cs
- UIAgentAsyncParams.cs
- XmlRootAttribute.cs
- ScaleTransform3D.cs
- TextPointerBase.cs
- TrustLevelCollection.cs
- EditorPartCollection.cs
- DataReceivedEventArgs.cs
- DuplicateWaitObjectException.cs
- ActivitySurrogate.cs
- DynamicResourceExtensionConverter.cs
- MultipartIdentifier.cs
- StrongNameUtility.cs
- TimeSpanValidatorAttribute.cs
- BezierSegment.cs
- ADConnectionHelper.cs
- FileVersion.cs
- Parsers.cs
- TimeStampChecker.cs
- RightsManagementManager.cs
- NetworkInformationException.cs
- WebRequest.cs
- OleDbError.cs
- TreeViewCancelEvent.cs
- StylusTip.cs
- WebPartVerbCollection.cs
- TraceContext.cs