Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / DataServiceProcessingPipeline.cs / 1305376 / DataServiceProcessingPipeline.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Class declaring events for the data service processing pipeline // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services { using System; using System.Diagnostics; ////// Class declaring the events for the data service processing pipeline /// public sealed class DataServiceProcessingPipeline { #if DEBUG // *************************************************************************************** // The debug code here is for basic assertions on call orders if the request is successful. // *************************************************************************************** ////// Number of times InvokeProcessingRequest() is called. /// private int ProcessingRequestInvokeCount; ////// Number of times InvokeProcessedRequest() is called /// private int ProcessedRequestInvokeCount; ////// Number of times InvokeProcessingChangeset() is called /// private int ProcessingChangesetInvokeCount; ////// Number of times InvokeProcessedChangeset() is called /// private int ProcessedChangesetInvokeCount; ////// Set to true if we have seen an exception in the current request or we are in the $metadata path /// ////// If the current request encounters an exception, there is no guarantee that all the /// events will be fired, we may skip the debug asserts when that happens. /// internal bool SkipDebugAssert; ////// Set to true if DataServiceProviderWrapper.GetService() is called. /// internal bool HasInstantiatedProviderInterfaces; ////// Set to true if any of the service is disposed from WebUtil.Dispose() /// internal bool HasDisposedProviderInterfaces; ////// Number of times DataService<T>.OnStartProcessingRequest() is called. /// internal int OnStartProcessingRequestInvokeCount; #endif ////// Request start event /// public event EventHandlerProcessingRequest; /// /// Request end event /// public event EventHandlerProcessedRequest; /// /// Change set start event /// public event EventHandlerProcessingChangeset; /// /// Change set end event /// public event EventHandlerProcessedChangeset; #if DEBUG /// /// Assert ProcessingPipeline state before any event has been fired /// internal void AssertInitialDebugState() { Debug.Assert(!this.HasInstantiatedProviderInterfaces, "!this.HasInstantiatedProviderInterfaces"); Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount == 0, "this.OnStartProcessingRequestInvokeCount == 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 0, "this.ProcessingRequestInvokeCount == 0"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); Debug.Assert(this.ProcessingChangesetInvokeCount == 0, "this.ProcessingChangesetInvokeCount == 0"); Debug.Assert(this.ProcessedChangesetInvokeCount == 0, "this.ProcessedChangesetInvokeCount == 0"); } ////// Assert ProcessingPipeline state at DataService<T>.OnStartProcessingRequest /// internal void AssertDebugStateAtOnStartProcessingRequest() { // If the current request encounters an exception, there is no guarantee that all the // events will be fired, we skip the debug asserts when that happens. if (!this.SkipDebugAssert) { Debug.Assert( this.OnStartProcessingRequestInvokeCount > 0 || !this.HasInstantiatedProviderInterfaces, "this.OnStartProcessingRequestInvokeCount > 0 || !this.HasInstantiatedProviderInterfaces"); Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); Debug.Assert( this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount || this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount || this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1"); } } ////// Assert ProcessingPipeline state before disposing provider interfaces /// internal void AssertDebugStateAtDispose() { // If the current request encounters an exception, there is no guarantee that all the // events will be fired, we skip the debug asserts when that happens. if (!this.SkipDebugAssert) { Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 1, "this.ProcessedRequestInvokeCount == 1"); Debug.Assert( this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount"); } } ////// Assert Processing Pipeline state during request processing /// /// data service instance internal void AssertDebugStateDuringRequestProcessing(IDataService dataService) { // If the current request encounters an exception, there is no guarantee that all the // events will be fired, we skip the debug asserts when that happens. if (!this.SkipDebugAssert) { Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert( (this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount && dataService.OperationContext.Host.AstoriaHttpVerb == AstoriaVerbs.GET) || (this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1 && dataService.OperationContext.Host.AstoriaHttpVerb != AstoriaVerbs.GET), "ProcessingChangesetInvokeCount must be 1 larger than ProcessedChangesetInvokeCount in CUD operation and they must be the same in a GET request."); } } ////// Need to be able to reset the states since the caller can reuse the same service instance. /// internal void ResetDebugState() { this.HasInstantiatedProviderInterfaces = false; this.HasDisposedProviderInterfaces = false; this.OnStartProcessingRequestInvokeCount = 0; this.ProcessingRequestInvokeCount = 0; this.ProcessedRequestInvokeCount = 0; this.ProcessingChangesetInvokeCount = 0; this.ProcessedChangesetInvokeCount = 0; } #endif ////// Invoke request start event /// /// Sender, i.e. data service instance. /// event arg internal void InvokeProcessingRequest(object sender, DataServiceProcessingPipelineEventArgs e) { #if DEBUG this.AssertInitialDebugState(); this.ProcessingRequestInvokeCount++; #endif if (this.ProcessingRequest != null) { this.ProcessingRequest(sender, e); } } ////// Invoke request end event /// /// Sender, i.e. data service instance. /// event arg internal void InvokeProcessedRequest(object sender, DataServiceProcessingPipelineEventArgs e) { #if DEBUG Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); if (!this.SkipDebugAssert) { Debug.Assert(this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount"); } this.ProcessedRequestInvokeCount++; #endif if (this.ProcessedRequest != null) { this.ProcessedRequest(sender, e); } } ////// Invoke change set start event /// /// Sender, i.e. data service instance. /// event arg internal void InvokeProcessingChangeset(object sender, EventArgs e) { #if DEBUG Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); if (!this.SkipDebugAssert) { Debug.Assert(this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount"); } this.ProcessingChangesetInvokeCount++; #endif if (this.ProcessingChangeset != null) { this.ProcessingChangeset(sender, e); } } ////// Invoke change set end event /// /// Sender, i.e. data service instance. /// event arg internal void InvokeProcessedChangeset(object sender, EventArgs e) { #if DEBUG Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); if (!this.SkipDebugAssert) { Debug.Assert(this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1"); } this.ProcessedChangesetInvokeCount++; #endif if (this.ProcessedChangeset != null) { this.ProcessedChangeset(sender, e); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Class declaring events for the data service processing pipeline // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services { using System; using System.Diagnostics; ////// Class declaring the events for the data service processing pipeline /// public sealed class DataServiceProcessingPipeline { #if DEBUG // *************************************************************************************** // The debug code here is for basic assertions on call orders if the request is successful. // *************************************************************************************** ////// Number of times InvokeProcessingRequest() is called. /// private int ProcessingRequestInvokeCount; ////// Number of times InvokeProcessedRequest() is called /// private int ProcessedRequestInvokeCount; ////// Number of times InvokeProcessingChangeset() is called /// private int ProcessingChangesetInvokeCount; ////// Number of times InvokeProcessedChangeset() is called /// private int ProcessedChangesetInvokeCount; ////// Set to true if we have seen an exception in the current request or we are in the $metadata path /// ////// If the current request encounters an exception, there is no guarantee that all the /// events will be fired, we may skip the debug asserts when that happens. /// internal bool SkipDebugAssert; ////// Set to true if DataServiceProviderWrapper.GetService() is called. /// internal bool HasInstantiatedProviderInterfaces; ////// Set to true if any of the service is disposed from WebUtil.Dispose() /// internal bool HasDisposedProviderInterfaces; ////// Number of times DataService<T>.OnStartProcessingRequest() is called. /// internal int OnStartProcessingRequestInvokeCount; #endif ////// Request start event /// public event EventHandlerProcessingRequest; /// /// Request end event /// public event EventHandlerProcessedRequest; /// /// Change set start event /// public event EventHandlerProcessingChangeset; /// /// Change set end event /// public event EventHandlerProcessedChangeset; #if DEBUG /// /// Assert ProcessingPipeline state before any event has been fired /// internal void AssertInitialDebugState() { Debug.Assert(!this.HasInstantiatedProviderInterfaces, "!this.HasInstantiatedProviderInterfaces"); Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount == 0, "this.OnStartProcessingRequestInvokeCount == 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 0, "this.ProcessingRequestInvokeCount == 0"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); Debug.Assert(this.ProcessingChangesetInvokeCount == 0, "this.ProcessingChangesetInvokeCount == 0"); Debug.Assert(this.ProcessedChangesetInvokeCount == 0, "this.ProcessedChangesetInvokeCount == 0"); } ////// Assert ProcessingPipeline state at DataService<T>.OnStartProcessingRequest /// internal void AssertDebugStateAtOnStartProcessingRequest() { // If the current request encounters an exception, there is no guarantee that all the // events will be fired, we skip the debug asserts when that happens. if (!this.SkipDebugAssert) { Debug.Assert( this.OnStartProcessingRequestInvokeCount > 0 || !this.HasInstantiatedProviderInterfaces, "this.OnStartProcessingRequestInvokeCount > 0 || !this.HasInstantiatedProviderInterfaces"); Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); Debug.Assert( this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount || this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount || this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1"); } } ////// Assert ProcessingPipeline state before disposing provider interfaces /// internal void AssertDebugStateAtDispose() { // If the current request encounters an exception, there is no guarantee that all the // events will be fired, we skip the debug asserts when that happens. if (!this.SkipDebugAssert) { Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 1, "this.ProcessedRequestInvokeCount == 1"); Debug.Assert( this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount"); } } ////// Assert Processing Pipeline state during request processing /// /// data service instance internal void AssertDebugStateDuringRequestProcessing(IDataService dataService) { // If the current request encounters an exception, there is no guarantee that all the // events will be fired, we skip the debug asserts when that happens. if (!this.SkipDebugAssert) { Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert( (this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount && dataService.OperationContext.Host.AstoriaHttpVerb == AstoriaVerbs.GET) || (this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1 && dataService.OperationContext.Host.AstoriaHttpVerb != AstoriaVerbs.GET), "ProcessingChangesetInvokeCount must be 1 larger than ProcessedChangesetInvokeCount in CUD operation and they must be the same in a GET request."); } } ////// Need to be able to reset the states since the caller can reuse the same service instance. /// internal void ResetDebugState() { this.HasInstantiatedProviderInterfaces = false; this.HasDisposedProviderInterfaces = false; this.OnStartProcessingRequestInvokeCount = 0; this.ProcessingRequestInvokeCount = 0; this.ProcessedRequestInvokeCount = 0; this.ProcessingChangesetInvokeCount = 0; this.ProcessedChangesetInvokeCount = 0; } #endif ////// Invoke request start event /// /// Sender, i.e. data service instance. /// event arg internal void InvokeProcessingRequest(object sender, DataServiceProcessingPipelineEventArgs e) { #if DEBUG this.AssertInitialDebugState(); this.ProcessingRequestInvokeCount++; #endif if (this.ProcessingRequest != null) { this.ProcessingRequest(sender, e); } } ////// Invoke request end event /// /// Sender, i.e. data service instance. /// event arg internal void InvokeProcessedRequest(object sender, DataServiceProcessingPipelineEventArgs e) { #if DEBUG Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); if (!this.SkipDebugAssert) { Debug.Assert(this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount"); } this.ProcessedRequestInvokeCount++; #endif if (this.ProcessedRequest != null) { this.ProcessedRequest(sender, e); } } ////// Invoke change set start event /// /// Sender, i.e. data service instance. /// event arg internal void InvokeProcessingChangeset(object sender, EventArgs e) { #if DEBUG Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); if (!this.SkipDebugAssert) { Debug.Assert(this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount"); } this.ProcessingChangesetInvokeCount++; #endif if (this.ProcessingChangeset != null) { this.ProcessingChangeset(sender, e); } } ////// Invoke change set end event /// /// Sender, i.e. data service instance. /// event arg internal void InvokeProcessedChangeset(object sender, EventArgs e) { #if DEBUG Debug.Assert(!this.HasDisposedProviderInterfaces, "!this.HasDisposedProviderInterfaces"); Debug.Assert(this.OnStartProcessingRequestInvokeCount > 0, "this.OnStartProcessingRequestInvokeCount > 0"); Debug.Assert(this.ProcessingRequestInvokeCount == 1, "this.ProcessingRequestInvokeCount == 1"); Debug.Assert(this.ProcessedRequestInvokeCount == 0, "this.ProcessedRequestInvokeCount == 0"); if (!this.SkipDebugAssert) { Debug.Assert(this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1, "this.ProcessingChangesetInvokeCount == this.ProcessedChangesetInvokeCount + 1"); } this.ProcessedChangesetInvokeCount++; #endif if (this.ProcessedChangeset != null) { this.ProcessedChangeset(sender, e); } } } } // 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
- BinHexEncoder.cs
- SoapHeader.cs
- TrackingCondition.cs
- MaterializeFromAtom.cs
- ErasingStroke.cs
- LayoutTable.cs
- QilExpression.cs
- WebPartAddingEventArgs.cs
- _ProxyChain.cs
- WindowsSysHeader.cs
- ItemList.cs
- Native.cs
- StatusBarPanelClickEvent.cs
- HtmlUtf8RawTextWriter.cs
- CacheForPrimitiveTypes.cs
- TreeNodeStyleCollection.cs
- WpfPayload.cs
- WebPartCloseVerb.cs
- RadioButtonFlatAdapter.cs
- DataServiceProviderWrapper.cs
- ConsumerConnectionPointCollection.cs
- PersonalizationEntry.cs
- ExpressionPrefixAttribute.cs
- ClientSettingsProvider.cs
- CryptoProvider.cs
- Crc32.cs
- PhonemeEventArgs.cs
- Reference.cs
- OutOfProcStateClientManager.cs
- XsltInput.cs
- ViewBase.cs
- OrderByBuilder.cs
- Wizard.cs
- MD5.cs
- ProcessInputEventArgs.cs
- JsonObjectDataContract.cs
- ServerValidateEventArgs.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- DisableDpiAwarenessAttribute.cs
- Helpers.cs
- CheckoutException.cs
- InkCanvas.cs
- HeaderedContentControl.cs
- ExpressionBuilder.cs
- Label.cs
- TablePattern.cs
- UrlAuthFailedErrorFormatter.cs
- FilterQuery.cs
- OdbcDataReader.cs
- ColumnClickEvent.cs
- WSHttpBinding.cs
- TextEditorTyping.cs
- HttpCookieCollection.cs
- XmlDataContract.cs
- JoinTreeNode.cs
- BounceEase.cs
- TimelineGroup.cs
- _ListenerResponseStream.cs
- PathFigure.cs
- UnsafeNativeMethods.cs
- CopyEncoder.cs
- EntityDataSourceView.cs
- DataGridViewTextBoxCell.cs
- RegionData.cs
- Package.cs
- EdmRelationshipRoleAttribute.cs
- Parameter.cs
- PolyQuadraticBezierSegment.cs
- DataPagerField.cs
- SerializableTypeCodeDomSerializer.cs
- UrlPath.cs
- Wizard.cs
- Model3DGroup.cs
- CompiledQueryCacheEntry.cs
- Util.cs
- ViewStateModeByIdAttribute.cs
- Switch.cs
- Helpers.cs
- PropertyTab.cs
- DrawingGroupDrawingContext.cs
- WmiInstallComponent.cs
- MediaElementAutomationPeer.cs
- _NestedSingleAsyncResult.cs
- Int32AnimationUsingKeyFrames.cs
- DesignerLabelAdapter.cs
- _TimerThread.cs
- FunctionImportElement.cs
- WindowProviderWrapper.cs
- TemplateLookupAction.cs
- EmptyControlCollection.cs
- CompressedStack.cs
- JoinSymbol.cs
- MessageQueueKey.cs
- StorageFunctionMapping.cs
- FolderBrowserDialog.cs
- MediaElementAutomationPeer.cs
- CallContext.cs
- CaseCqlBlock.cs
- LinkUtilities.cs
- SafeBuffer.cs