Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Providers / ServiceOperationWrapper.cs / 1305376 / ServiceOperationWrapper.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Wrapper class for ServiceOperation so we can store service
// specific data here.
//
//
// @owner [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Providers
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
/// Use this class to represent a custom service operation.
[DebuggerVisualizer("ServiceOperation={Name}")]
internal sealed class ServiceOperationWrapper
{
#region Private Fields
///
/// Wrapped instance of the service operation.
///
private readonly ServiceOperation serviceOperation;
/// Access rights to this service operation.
private ServiceOperationRights rights;
/// Entity set from which entities are read, if applicable.
private ResourceSetWrapper resourceSet;
#if DEBUG
/// Is true, if the service operation is fully initialized and validated. No more changes can be made once its set to readonly.
private bool isReadOnly;
#endif
#endregion Private Fields
#region Constructor
///
/// Initializes a new instance.
///
/// ServiceOperation instance to be wrapped.
public ServiceOperationWrapper(ServiceOperation serviceOperation)
{
Debug.Assert(serviceOperation != null, "serviceOperation != null");
if (!serviceOperation.IsReadOnly)
{
throw new DataServiceException(500, Strings.DataServiceProviderWrapper_ServiceOperationNotReadonly(serviceOperation.Name));
}
this.serviceOperation = serviceOperation;
}
#endregion Constructor
#region Properties
/// Protocol (for example HTTP) method the service operation responds to.
public string Method
{
[DebuggerStepThrough]
get { return this.serviceOperation.Method; }
}
/// MIME type specified on primitive results, possibly null.
public string MimeType
{
[DebuggerStepThrough]
get { return this.serviceOperation.MimeType; }
}
/// Name of the service operation.
public string Name
{
[DebuggerStepThrough]
get { return this.serviceOperation.Name; }
}
/// Returns all the parameters for the given service operations.///
public ReadOnlyCollection Parameters
{
[DebuggerStepThrough]
get { return this.serviceOperation.Parameters; }
}
/// Kind of result expected from this operation.
public ServiceOperationResultKind ResultKind
{
[DebuggerStepThrough]
get { return this.serviceOperation.ResultKind; }
}
/// Element of result type.
///
/// Note that if the method returns an IEnumerable<string>,
/// this property will be typeof(string).
///
public ResourceType ResultType
{
[DebuggerStepThrough]
get { return this.serviceOperation.ResultType; }
}
///
/// Gets the wrapped service operation
///
public ServiceOperation ServiceOperation
{
[DebuggerStepThrough]
get { return this.serviceOperation; }
}
/// Whether the operation is visible to service consumers.
public bool IsVisible
{
[DebuggerStepThrough]
get
{
#if DEBUG
Debug.Assert(this.isReadOnly, "Wrapper class has not been initialized yet.");
#endif
return (this.rights & ~ServiceOperationRights.OverrideEntitySetRights) != ServiceOperationRights.None;
}
}
/// Access rights to this service operation.
public ServiceOperationRights Rights
{
[DebuggerStepThrough]
get
{
#if DEBUG
Debug.Assert(this.isReadOnly, "Wrapper class has not been initialized yet.");
#endif
return this.rights;
}
}
/// Entity set from which entities are read (possibly null).
public ResourceSetWrapper ResourceSet
{
[DebuggerStepThrough]
get
{
#if DEBUG
Debug.Assert(this.isReadOnly, "Wrapper class has not been initialized yet.");
#endif
Debug.Assert(
this.serviceOperation.ResourceSet == null || this.resourceSet.ResourceSet == this.serviceOperation.ResourceSet,
"this.serviceOperation.ResourceSet == null || this.resourceSet.ResourceSet == this.serviceOperation.ResourceSet");
return this.resourceSet;
}
}
#endregion Properties
///
/// Apply the given configuration to the resource set.
///
/// data service configuration instance.
/// data service provider wrapper instance for accessibility validation.
public void ApplyConfiguration(DataServiceConfiguration configuration, DataServiceProviderWrapper provider)
{
#if DEBUG
Debug.Assert(!this.isReadOnly, "Can only apply the configuration once.");
#endif
this.rights = configuration.GetServiceOperationRights(this.serviceOperation);
if ((this.rights & ~ServiceOperationRights.OverrideEntitySetRights) != ServiceOperationRights.None)
{
if (this.serviceOperation.ResourceSet != null)
{
// If the result type is an entity type, we need to make sure its entity set is visible.
// If the entity set is hidden, we need to make sure that we throw an exception.
this.resourceSet = provider.TryResolveResourceSet(this.serviceOperation.ResourceSet.Name);
if (this.resourceSet == null)
{
throw new InvalidOperationException(Strings.BaseServiceProvider_ServiceOperationTypeHasNoContainer(this.serviceOperation.Name, this.serviceOperation.ResultType.FullName));
}
}
}
#if DEBUG
this.isReadOnly = true;
#endif
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Wrapper class for ServiceOperation so we can store service
// specific data here.
//
//
// @owner [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Providers
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
/// Use this class to represent a custom service operation.
[DebuggerVisualizer("ServiceOperation={Name}")]
internal sealed class ServiceOperationWrapper
{
#region Private Fields
///
/// Wrapped instance of the service operation.
///
private readonly ServiceOperation serviceOperation;
/// Access rights to this service operation.
private ServiceOperationRights rights;
/// Entity set from which entities are read, if applicable.
private ResourceSetWrapper resourceSet;
#if DEBUG
/// Is true, if the service operation is fully initialized and validated. No more changes can be made once its set to readonly.
private bool isReadOnly;
#endif
#endregion Private Fields
#region Constructor
///
/// Initializes a new instance.
///
/// ServiceOperation instance to be wrapped.
public ServiceOperationWrapper(ServiceOperation serviceOperation)
{
Debug.Assert(serviceOperation != null, "serviceOperation != null");
if (!serviceOperation.IsReadOnly)
{
throw new DataServiceException(500, Strings.DataServiceProviderWrapper_ServiceOperationNotReadonly(serviceOperation.Name));
}
this.serviceOperation = serviceOperation;
}
#endregion Constructor
#region Properties
/// Protocol (for example HTTP) method the service operation responds to.
public string Method
{
[DebuggerStepThrough]
get { return this.serviceOperation.Method; }
}
/// MIME type specified on primitive results, possibly null.
public string MimeType
{
[DebuggerStepThrough]
get { return this.serviceOperation.MimeType; }
}
/// Name of the service operation.
public string Name
{
[DebuggerStepThrough]
get { return this.serviceOperation.Name; }
}
/// Returns all the parameters for the given service operations.///
public ReadOnlyCollection Parameters
{
[DebuggerStepThrough]
get { return this.serviceOperation.Parameters; }
}
/// Kind of result expected from this operation.
public ServiceOperationResultKind ResultKind
{
[DebuggerStepThrough]
get { return this.serviceOperation.ResultKind; }
}
/// Element of result type.
///
/// Note that if the method returns an IEnumerable<string>,
/// this property will be typeof(string).
///
public ResourceType ResultType
{
[DebuggerStepThrough]
get { return this.serviceOperation.ResultType; }
}
///
/// Gets the wrapped service operation
///
public ServiceOperation ServiceOperation
{
[DebuggerStepThrough]
get { return this.serviceOperation; }
}
/// Whether the operation is visible to service consumers.
public bool IsVisible
{
[DebuggerStepThrough]
get
{
#if DEBUG
Debug.Assert(this.isReadOnly, "Wrapper class has not been initialized yet.");
#endif
return (this.rights & ~ServiceOperationRights.OverrideEntitySetRights) != ServiceOperationRights.None;
}
}
/// Access rights to this service operation.
public ServiceOperationRights Rights
{
[DebuggerStepThrough]
get
{
#if DEBUG
Debug.Assert(this.isReadOnly, "Wrapper class has not been initialized yet.");
#endif
return this.rights;
}
}
/// Entity set from which entities are read (possibly null).
public ResourceSetWrapper ResourceSet
{
[DebuggerStepThrough]
get
{
#if DEBUG
Debug.Assert(this.isReadOnly, "Wrapper class has not been initialized yet.");
#endif
Debug.Assert(
this.serviceOperation.ResourceSet == null || this.resourceSet.ResourceSet == this.serviceOperation.ResourceSet,
"this.serviceOperation.ResourceSet == null || this.resourceSet.ResourceSet == this.serviceOperation.ResourceSet");
return this.resourceSet;
}
}
#endregion Properties
///
/// Apply the given configuration to the resource set.
///
/// data service configuration instance.
/// data service provider wrapper instance for accessibility validation.
public void ApplyConfiguration(DataServiceConfiguration configuration, DataServiceProviderWrapper provider)
{
#if DEBUG
Debug.Assert(!this.isReadOnly, "Can only apply the configuration once.");
#endif
this.rights = configuration.GetServiceOperationRights(this.serviceOperation);
if ((this.rights & ~ServiceOperationRights.OverrideEntitySetRights) != ServiceOperationRights.None)
{
if (this.serviceOperation.ResourceSet != null)
{
// If the result type is an entity type, we need to make sure its entity set is visible.
// If the entity set is hidden, we need to make sure that we throw an exception.
this.resourceSet = provider.TryResolveResourceSet(this.serviceOperation.ResourceSet.Name);
if (this.resourceSet == null)
{
throw new InvalidOperationException(Strings.BaseServiceProvider_ServiceOperationTypeHasNoContainer(this.serviceOperation.Name, this.serviceOperation.ResultType.FullName));
}
}
}
#if DEBUG
this.isReadOnly = true;
#endif
}
}
}
// 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
- basenumberconverter.cs
- XmlDataLoader.cs
- SystemIcmpV6Statistics.cs
- PersonalizableAttribute.cs
- Buffer.cs
- ModelServiceImpl.cs
- HttpCookiesSection.cs
- SurrogateSelector.cs
- ConfigurationElementCollection.cs
- StatusBarAutomationPeer.cs
- XpsSerializerWriter.cs
- TablePatternIdentifiers.cs
- ProviderConnectionPoint.cs
- KeyedHashAlgorithm.cs
- DesignerActionUIStateChangeEventArgs.cs
- KnownAssembliesSet.cs
- MdImport.cs
- SessionStateSection.cs
- FormatConvertedBitmap.cs
- LinearKeyFrames.cs
- ModelPropertyCollectionImpl.cs
- TimeoutHelper.cs
- ScriptingSectionGroup.cs
- Transform3DGroup.cs
- DataGridPageChangedEventArgs.cs
- AttachedAnnotationChangedEventArgs.cs
- PersonalizationProviderCollection.cs
- ReaderWriterLockSlim.cs
- IERequestCache.cs
- RelationshipConverter.cs
- glyphs.cs
- PrivilegedConfigurationManager.cs
- LookupNode.cs
- ResXBuildProvider.cs
- VisualStyleInformation.cs
- ServiceModelConfigurationElementCollection.cs
- XmlText.cs
- ParameterBuilder.cs
- InstanceLockQueryResult.cs
- FixedNode.cs
- PropertyCondition.cs
- SimpleWebHandlerParser.cs
- WebResponse.cs
- DriveInfo.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- UnsafeNativeMethods.cs
- TypeReference.cs
- EditingCoordinator.cs
- securitycriticaldata.cs
- PeerObject.cs
- SoapEnumAttribute.cs
- ComPlusSynchronizationContext.cs
- XmlSerializerFactory.cs
- AppSettingsSection.cs
- TableItemPatternIdentifiers.cs
- BitmapEffectInputData.cs
- CustomGrammar.cs
- RequestCachingSection.cs
- Triangle.cs
- CodeAttributeArgument.cs
- ContainsRowNumberChecker.cs
- IdentityNotMappedException.cs
- WebPartRestoreVerb.cs
- TextParagraphView.cs
- MethodToken.cs
- VisualProxy.cs
- Set.cs
- UrlRoutingModule.cs
- FileSystemEventArgs.cs
- ScopelessEnumAttribute.cs
- PrePrepareMethodAttribute.cs
- FixedDSBuilder.cs
- DiagnosticTraceSource.cs
- SpeakProgressEventArgs.cs
- GenericRootAutomationPeer.cs
- CompModSwitches.cs
- EventData.cs
- DataGridViewButtonColumn.cs
- RequestQueryProcessor.cs
- BlockCollection.cs
- EraserBehavior.cs
- AssociatedControlConverter.cs
- ConstraintConverter.cs
- PipelineModuleStepContainer.cs
- HwndTarget.cs
- ImplicitInputBrush.cs
- XmlSchemaComplexType.cs
- updatecommandorderer.cs
- Vector.cs
- Monitor.cs
- RemotingAttributes.cs
- LOSFormatter.cs
- RichTextBoxConstants.cs
- CFStream.cs
- StringWriter.cs
- PrincipalPermission.cs
- AssociationSetMetadata.cs
- AmbientProperties.cs
- BitmapFrameDecode.cs
- Expressions.cs