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
- FactoryGenerator.cs
- XmlSchemaInclude.cs
- ExpressionEvaluator.cs
- DataAccessor.cs
- PointCollectionConverter.cs
- SettingsPropertyIsReadOnlyException.cs
- JapaneseCalendar.cs
- DataGridViewCheckBoxCell.cs
- HttpChannelBindingToken.cs
- TracingConnectionInitiator.cs
- _OSSOCK.cs
- BevelBitmapEffect.cs
- CacheSection.cs
- PbrsForward.cs
- RequiredFieldValidator.cs
- ProviderConnectionPointCollection.cs
- DataGridViewBindingCompleteEventArgs.cs
- ChannelManager.cs
- StringArrayConverter.cs
- HostedNamedPipeTransportManager.cs
- File.cs
- Random.cs
- GeometryHitTestResult.cs
- ITreeGenerator.cs
- ComboBoxRenderer.cs
- XmlSchemaProviderAttribute.cs
- _CookieModule.cs
- DecimalConverter.cs
- DataGridView.cs
- ContainerSelectorActiveEvent.cs
- MemberCollection.cs
- ActiveXContainer.cs
- OAVariantLib.cs
- RepeatButton.cs
- SwitchCase.cs
- ErrorTableItemStyle.cs
- PageContentAsyncResult.cs
- ProtocolImporter.cs
- SamlSecurityTokenAuthenticator.cs
- DataGridColumn.cs
- Matrix.cs
- PeerToPeerException.cs
- ExpressionConverter.cs
- StatusBar.cs
- ImageUrlEditor.cs
- FixedBufferAttribute.cs
- TypeToken.cs
- RenderingBiasValidation.cs
- Color.cs
- AncestorChangedEventArgs.cs
- StorageMappingItemLoader.cs
- SqlResolver.cs
- OdbcUtils.cs
- MailAddress.cs
- HierarchicalDataTemplate.cs
- NullableIntMinMaxAggregationOperator.cs
- IntSecurity.cs
- ComponentEditorForm.cs
- StylusPointDescription.cs
- TreeViewItem.cs
- ToolStripPanelRenderEventArgs.cs
- FileClassifier.cs
- DataGridSortCommandEventArgs.cs
- MatrixTransform3D.cs
- RemoteWebConfigurationHostStream.cs
- ActivityExecutionFilter.cs
- ControlIdConverter.cs
- CultureInfoConverter.cs
- DataReaderContainer.cs
- ProxySimple.cs
- SByteConverter.cs
- HyperlinkAutomationPeer.cs
- TextOnlyOutput.cs
- DoubleLink.cs
- RSACryptoServiceProvider.cs
- NonSerializedAttribute.cs
- SqlNodeAnnotations.cs
- SqlColumnizer.cs
- UICuesEvent.cs
- PtsCache.cs
- CodePageEncoding.cs
- WorkflowOperationBehavior.cs
- PropertyGridCommands.cs
- DataGridRow.cs
- DESCryptoServiceProvider.cs
- ErrorWrapper.cs
- StringFreezingAttribute.cs
- TypefaceMetricsCache.cs
- Transaction.cs
- CookielessHelper.cs
- ProtocolsConfiguration.cs
- TextTreeUndo.cs
- CodeCompileUnit.cs
- MenuBase.cs
- DataKeyArray.cs
- SecUtil.cs
- ParameterCollectionEditorForm.cs
- FloaterParagraph.cs
- SessionPageStatePersister.cs
- XmlSerializerFactory.cs