Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Providers / ResourceContainerWrapper.cs / 1305376 / ResourceContainerWrapper.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Wrapper class for a resource set. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Providers { #region Namespaces. using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; #endregion Namespaces. ////// Wrapper class for a resource set. A resource set object can be shared across services, /// this wrapper class contains the resouce set information and also service specific /// information about that resource set. /// [DebuggerDisplay("{Name}: {ResourceType}")] internal class ResourceSetWrapper { #region Fields ///Reference to the wrapped resource set private readonly ResourceSet resourceSet; ///Reference to the wrapped resource type. private readonly ResourceType resourceType; ///Access rights to this resource set. private EntitySetRights rights; ///Page Size for this resource set. private int pageSize; ///Methods to be called when composing read queries to allow authorization. private MethodInfo[] readAuthorizationMethods; ///Methods to be called when validating write methods to allow authorization. private MethodInfo[] writeAuthorizationMethods; ///Whether the types contained in the set has mappings for friendly feeds are V1 compatible or not private bool? epmIsV1Compatible; #if DEBUG ///Is true, if the resource set is fully initialized and validated. No more changes can be made once its set to readonly. private bool isReadOnly; #endif #endregion Fields #region Constructors ////// Constructs a new ResourceSetWrapper instance using the ResourceSet instance to be enclosed. /// /// ResourceSet instance to be wrapped by the current instance /// Resource type (normalized to a single instance by the caller). public ResourceSetWrapper(ResourceSet resourceSet, ResourceType resourceType) { Debug.Assert(resourceSet != null, "resourceSet != null"); if (!resourceSet.IsReadOnly) { throw new DataServiceException(500, Strings.DataServiceProviderWrapper_ResourceContainerNotReadonly(resourceSet.Name)); } this.resourceSet = resourceSet; this.resourceType = resourceType; } #endregion Constructors #region Properties ///Name of the resource set. public string Name { get { return this.resourceSet.Name; } } ///Reference to resource type that this resource set is a collection of public ResourceType ResourceType { get { return this.resourceType; } } ///Whether the resource set is visible to service consumers. public bool IsVisible { get { #if DEBUG Debug.Assert(this.isReadOnly, "IsVisible - entity set settings not initialized."); #endif return this.rights != EntitySetRights.None; } } ///Access rights to this resource set. public EntitySetRights Rights { get { #if DEBUG Debug.Assert(this.isReadOnly, "Rights - entity set settings not initialized."); #endif return this.rights; } } ///Page Size for this resource set. public int PageSize { get { #if DEBUG Debug.Assert(this.isReadOnly, "Rights - entity set settings not initialized."); #endif return this.pageSize; } } ///Retursn the list of query interceptors for this set (possibly null). public MethodInfo[] QueryInterceptors { [DebuggerStepThrough] get { #if DEBUG Debug.Assert(this.isReadOnly, "QueryInterceptors - entity set settings not initialized."); #endif return this.readAuthorizationMethods; } } ///Returns the list of change interceptors for this set (possible null). public MethodInfo[] ChangeInterceptors { [DebuggerStepThrough] get { #if DEBUG Debug.Assert(this.isReadOnly, "ChangeInterceptors - entity set settings not initialized."); #endif return this.writeAuthorizationMethods; } } ///Returns the wrapped resource set instance. internal ResourceSet ResourceSet { [DebuggerStepThrough] get { #if DEBUG Debug.Assert(this.resourceSet != null, "this.resourceSet != null"); #endif return this.resourceSet; } } #endregion Properties #region Methods ////// Apply the given configuration to the resource set. /// /// data service configuration instance. public void ApplyConfiguration(DataServiceConfiguration configuration) { #if DEBUG Debug.Assert(!this.isReadOnly, "Can only apply the configuration once."); #endif // Set entity set rights this.rights = configuration.GetResourceSetRights(this.resourceSet); // Set page size this.pageSize = configuration.GetResourceSetPageSize(this.resourceSet); if (this.pageSize < 0) { throw new DataServiceException(500, Strings.DataService_SDP_PageSizeMustbeNonNegative(this.pageSize, this.Name)); } // Add QueryInterceptors this.readAuthorizationMethods = configuration.GetReadAuthorizationMethods(this.resourceSet); // Add ChangeInterceptors this.writeAuthorizationMethods = configuration.GetWriteAuthorizationMethods(this.resourceSet); #if DEBUG this.isReadOnly = true; #endif } ///Whether the types contained in the set has mappings for friendly feeds are V1 compatible or not /// Data service provider instance. ///False if there's any type in this set which has friendly feed mappings with KeepInContent=false. True otherwise. internal bool EpmIsV1Compatible(DataServiceProviderWrapper provider) { #if DEBUG Debug.Assert(provider != null, "provider != null"); Debug.Assert(this.resourceSet != null, "this.resourceSet != null"); Debug.Assert(this.isReadOnly, "EpmIsV1Compatible - entity set settings not initialized."); #endif if (!this.epmIsV1Compatible.HasValue) { // Go through all types contained in the set. If any one type is EpmIsV1Compatible == false, // the whole set is EpmIsV1Compatible=false. ResourceType baseType = this.resourceSet.ResourceType; bool isV1Compatible = baseType.EpmIsV1Compatible; // If the base type is not epm v1 compatible or it has no derived type, we need not look any further. if (isV1Compatible && provider.HasDerivedTypes(baseType)) { foreach (ResourceType derivedType in provider.GetDerivedTypes(baseType)) { if (!derivedType.EpmIsV1Compatible) { // We can stop as soon as we find the first type that is not epm v1 compatible. isV1Compatible = false; break; } } } this.epmIsV1Compatible = isV1Compatible; } return this.epmIsV1Compatible.Value; } #endregion Methods } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AsyncOperationManager.cs
- StringBuilder.cs
- ItemType.cs
- TypedAsyncResult.cs
- UserControl.cs
- DataGridViewRowHeaderCell.cs
- ObjectQueryProvider.cs
- RSATokenProvider.cs
- FrameworkTemplate.cs
- UnsafeNativeMethods.cs
- mediapermission.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- base64Transforms.cs
- OutputCacheProfileCollection.cs
- XPathDocumentBuilder.cs
- ListControl.cs
- SqlColumnizer.cs
- XmlSchemaSimpleContentExtension.cs
- DiscoveryClientChannelBase.cs
- ValueTypeFixupInfo.cs
- BuilderPropertyEntry.cs
- BuildDependencySet.cs
- LinqDataSourceValidationException.cs
- MatrixTransform3D.cs
- HttpConfigurationContext.cs
- BrowserDefinition.cs
- FullTextLine.cs
- validationstate.cs
- WebHttpBinding.cs
- Perspective.cs
- ServiceThrottlingBehavior.cs
- ProtocolImporter.cs
- GroupItemAutomationPeer.cs
- DataGridRowAutomationPeer.cs
- LineSegment.cs
- ObjectDataSource.cs
- TimestampInformation.cs
- MenuAutoFormat.cs
- TextBoxAutoCompleteSourceConverter.cs
- CustomErrorsSectionWrapper.cs
- VectorKeyFrameCollection.cs
- HandleCollector.cs
- LinearGradientBrush.cs
- FrameworkContentElement.cs
- EncoderExceptionFallback.cs
- XamlWriter.cs
- TypeUsageBuilder.cs
- SerialPort.cs
- SimplePropertyEntry.cs
- MachineSettingsSection.cs
- CompositeTypefaceMetrics.cs
- IFlowDocumentViewer.cs
- EventDescriptor.cs
- TemplateXamlTreeBuilder.cs
- DataStreams.cs
- XmlHierarchicalEnumerable.cs
- SmtpLoginAuthenticationModule.cs
- DtdParser.cs
- WindowsRebar.cs
- Roles.cs
- CapabilitiesSection.cs
- ExpressionBuilder.cs
- DisplayToken.cs
- EdmToObjectNamespaceMap.cs
- FormConverter.cs
- FileClassifier.cs
- RtfToXamlReader.cs
- TextModifierScope.cs
- Rotation3DKeyFrameCollection.cs
- EventlogProvider.cs
- LinqToSqlWrapper.cs
- HotSpot.cs
- SQLDateTimeStorage.cs
- WindowsPrincipal.cs
- IdentityModelDictionary.cs
- SafeLibraryHandle.cs
- PasswordRecoveryAutoFormat.cs
- HeaderUtility.cs
- AnimatedTypeHelpers.cs
- Tablet.cs
- WeakRefEnumerator.cs
- AccessViolationException.cs
- DataListItemCollection.cs
- SafeHandles.cs
- EncoderNLS.cs
- SizeIndependentAnimationStorage.cs
- BackoffTimeoutHelper.cs
- TemplateBuilder.cs
- Timer.cs
- Decoder.cs
- TemplateContentLoader.cs
- GradientBrush.cs
- ProcessRequestAsyncResult.cs
- EndPoint.cs
- MenuTracker.cs
- SchemaAttDef.cs
- HttpListenerException.cs
- ExpressionBindings.cs
- SqlFunctionAttribute.cs
- PointAnimationUsingKeyFrames.cs