Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------------------- //// 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
- JournalNavigationScope.cs
- MessagingActivityHelper.cs
- FrugalMap.cs
- ISessionStateStore.cs
- ErrorEventArgs.cs
- EntityParameter.cs
- ListView.cs
- ObjectDataSourceSelectingEventArgs.cs
- ACE.cs
- MDIClient.cs
- BitArray.cs
- BamlWriter.cs
- Utility.cs
- DataPointer.cs
- SqlDataSourceCache.cs
- ServiceModelEnumValidator.cs
- AsyncOperationManager.cs
- DefaultPrintController.cs
- CodeSubDirectoriesCollection.cs
- filewebrequest.cs
- TokenFactoryFactory.cs
- ContextStaticAttribute.cs
- VolatileEnlistmentMultiplexing.cs
- OdbcParameter.cs
- SelectionProcessor.cs
- SubMenuStyle.cs
- SqlPersonalizationProvider.cs
- CodeMemberProperty.cs
- IdentityReference.cs
- DataGridViewColumnCollectionDialog.cs
- BaseAsyncResult.cs
- PackUriHelper.cs
- TriggerActionCollection.cs
- ImageMap.cs
- MsmqInputChannelListenerBase.cs
- MultidimensionalArrayItemReference.cs
- MetadataImporterQuotas.cs
- ColumnMapProcessor.cs
- Pair.cs
- PersonalizationStateInfoCollection.cs
- WebControl.cs
- Single.cs
- WmlPhoneCallAdapter.cs
- WaveHeader.cs
- Popup.cs
- AutomationPropertyInfo.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- MDIWindowDialog.cs
- PersistNameAttribute.cs
- Vector3D.cs
- MasterPage.cs
- WebPart.cs
- FileEnumerator.cs
- NativeMethods.cs
- ContainerControl.cs
- XPathEmptyIterator.cs
- translator.cs
- _HeaderInfo.cs
- SelectionPattern.cs
- TcpProcessProtocolHandler.cs
- _SafeNetHandles.cs
- _BasicClient.cs
- SortQuery.cs
- PropagatorResult.cs
- TdsRecordBufferSetter.cs
- ZoneButton.cs
- EditorZoneBase.cs
- KeyInstance.cs
- ExecutionContext.cs
- SHA1Managed.cs
- WebPartCatalogCloseVerb.cs
- login.cs
- UnmanagedMemoryStreamWrapper.cs
- RC2CryptoServiceProvider.cs
- ConnectionsZone.cs
- SourceFileBuildProvider.cs
- SimpleHandlerBuildProvider.cs
- FilteredDataSetHelper.cs
- SerialReceived.cs
- ResourceIDHelper.cs
- MatcherBuilder.cs
- PolyBezierSegment.cs
- LinqDataSourceDeleteEventArgs.cs
- LogEntrySerializer.cs
- TypeSystem.cs
- AssertUtility.cs
- DocumentOrderComparer.cs
- Triangle.cs
- QuotaExceededException.cs
- UInt16Storage.cs
- ProtocolElementCollection.cs
- GlyphTypeface.cs
- HierarchicalDataSourceDesigner.cs
- recordstatescratchpad.cs
- NominalTypeEliminator.cs
- TextProperties.cs
- DbProviderFactories.cs
- DataSourceSelectArguments.cs
- DataSourceXmlSubItemAttribute.cs
- controlskin.cs