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
- Avt.cs
- TextServicesContext.cs
- Style.cs
- ServiceReference.cs
- XmlNode.cs
- PipelineDeploymentState.cs
- StringArrayEditor.cs
- GridItemCollection.cs
- hresults.cs
- EntityEntry.cs
- FontFamily.cs
- PageThemeBuildProvider.cs
- ToolStripDropDownMenu.cs
- SQLMoneyStorage.cs
- SecurityCredentialsManager.cs
- InkCanvasInnerCanvas.cs
- ConsumerConnectionPoint.cs
- SequentialWorkflowHeaderFooter.cs
- ConnectionsZone.cs
- UserNameSecurityTokenAuthenticator.cs
- DataGridItemEventArgs.cs
- PageHandlerFactory.cs
- PixelFormats.cs
- WindowShowOrOpenTracker.cs
- InkCollectionBehavior.cs
- PolyLineSegmentFigureLogic.cs
- WindowsRichEditRange.cs
- PropertySegmentSerializationProvider.cs
- OutputWindow.cs
- ThreadPool.cs
- ReceiveMessageAndVerifySecurityAsyncResultBase.cs
- AnnotationHighlightLayer.cs
- XPathNavigator.cs
- TextTreeText.cs
- SolidBrush.cs
- CheckoutException.cs
- NumberSubstitution.cs
- MeasureItemEvent.cs
- MimeParameterWriter.cs
- KeyValueConfigurationElement.cs
- safex509handles.cs
- MouseOverProperty.cs
- XmlSchema.cs
- LogLogRecordHeader.cs
- CodeNamespaceCollection.cs
- XPathAncestorIterator.cs
- IImplicitResourceProvider.cs
- ItemDragEvent.cs
- OperationAbortedException.cs
- Quack.cs
- DiscoveryClientDocuments.cs
- CodeRemoveEventStatement.cs
- OptimalBreakSession.cs
- TextSpan.cs
- ValueType.cs
- ExpressionBindingCollection.cs
- basecomparevalidator.cs
- NameValueFileSectionHandler.cs
- QueryStringHandler.cs
- XmlQueryType.cs
- FilteredAttributeCollection.cs
- DataGridPreparingCellForEditEventArgs.cs
- TreeBuilder.cs
- Stack.cs
- PageSettings.cs
- AutoGeneratedFieldProperties.cs
- CodePropertyReferenceExpression.cs
- Restrictions.cs
- RouteValueDictionary.cs
- ConfigurationLocation.cs
- XmlAttributeProperties.cs
- ToolBarPanel.cs
- WindowsTreeView.cs
- LinkGrep.cs
- DatePickerTextBox.cs
- QuestionEventArgs.cs
- GeneralTransform3DGroup.cs
- EmptyStringExpandableObjectConverter.cs
- ThrowHelper.cs
- StateItem.cs
- EmptyQuery.cs
- CodeStatement.cs
- ViewKeyConstraint.cs
- ListViewUpdateEventArgs.cs
- ImageAttributes.cs
- CapabilitiesPattern.cs
- Application.cs
- PkcsUtils.cs
- ObjectSet.cs
- DebugInfoGenerator.cs
- DoubleAnimation.cs
- DragCompletedEventArgs.cs
- SystemIPv6InterfaceProperties.cs
- ExceptionWrapper.cs
- WebPartAuthorizationEventArgs.cs
- RoutedEventHandlerInfo.cs
- BuildResult.cs
- WorkerRequest.cs
- Message.cs
- SetMemberBinder.cs