Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / BufferedMessageData.cs / 1 / BufferedMessageData.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.IO; using System.Xml; using System.Text; using System.Collections.Generic; abstract class BufferedMessageData : IBufferedMessageData { ArraySegmentbuffer; BufferManager bufferManager; int refCount; int outstandingReaders; bool multipleUsers; RecycledMessageState messageState; SynchronizedPool messageStatePool; public BufferedMessageData(SynchronizedPool messageStatePool) { this.messageStatePool = messageStatePool; } public ArraySegment Buffer { get { return buffer; } } public BufferManager BufferManager { get { return bufferManager; } } public virtual XmlDictionaryReaderQuotas Quotas { get { return XmlDictionaryReaderQuotas.Max; } } public abstract MessageEncoder MessageEncoder { get; } object ThisLock { get { return this; } } public void EnableMultipleUsers() { multipleUsers = true; } public void Close() { if (multipleUsers) { lock (ThisLock) { if (--this.refCount == 0) { DoClose(); } } } else { DoClose(); } } void DoClose() { bufferManager.ReturnBuffer(buffer.Array); if (outstandingReaders == 0) { bufferManager = null; buffer = new ArraySegment (); OnClosed(); } } public void DoReturnMessageState(RecycledMessageState messageState) { if (this.messageState == null) { this.messageState = messageState; } else { messageStatePool.Return(messageState); } } void DoReturnXmlReader(XmlDictionaryReader reader) { ReturnXmlReader(reader); outstandingReaders--; } public RecycledMessageState DoTakeMessageState() { RecycledMessageState messageState = this.messageState; if (messageState != null) { this.messageState = null; return messageState; } else { return messageStatePool.Take(); } } XmlDictionaryReader DoTakeXmlReader() { XmlDictionaryReader reader = TakeXmlReader(); outstandingReaders++; return reader; } public XmlDictionaryReader GetMessageReader() { if (multipleUsers) { lock (ThisLock) { return DoTakeXmlReader(); } } else { return DoTakeXmlReader(); } } public void OnXmlReaderClosed(XmlDictionaryReader reader) { if (multipleUsers) { lock (ThisLock) { DoReturnXmlReader(reader); } } else { DoReturnXmlReader(reader); } } protected virtual void OnClosed() { } public RecycledMessageState TakeMessageState() { if (multipleUsers) { lock (ThisLock) { return DoTakeMessageState(); } } else { return DoTakeMessageState(); } } protected abstract XmlDictionaryReader TakeXmlReader(); public void Open() { lock (ThisLock) { this.refCount++; } } public void Open(ArraySegment buffer, BufferManager bufferManager) { this.refCount = 1; this.bufferManager = bufferManager; this.buffer = buffer; multipleUsers = false; } protected abstract void ReturnXmlReader(XmlDictionaryReader xmlReader); public void ReturnMessageState(RecycledMessageState messageState) { if (multipleUsers) { lock (ThisLock) { DoReturnMessageState(messageState); } } else { DoReturnMessageState(messageState); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Process.cs
- objectquery_tresulttype.cs
- XmlSchemaChoice.cs
- DbgUtil.cs
- TextEditorContextMenu.cs
- WorkflowInstanceExtensionCollection.cs
- TrackingRecord.cs
- XPathNodeHelper.cs
- TreeViewImageIndexConverter.cs
- LambdaSerializationException.cs
- MessageBox.cs
- ConnectionOrientedTransportChannelFactory.cs
- SharedStatics.cs
- ProcessManager.cs
- DataStreams.cs
- AttributedMetaModel.cs
- ComponentEditorPage.cs
- StyleCollection.cs
- HttpWrapper.cs
- MenuItem.cs
- MailSettingsSection.cs
- QilPatternFactory.cs
- BeginStoryboard.cs
- WindowsImpersonationContext.cs
- KnownBoxes.cs
- CompilerResults.cs
- XmlQueryContext.cs
- ImageKeyConverter.cs
- XappLauncher.cs
- MetadataItemEmitter.cs
- StringFunctions.cs
- RegularExpressionValidator.cs
- Dispatcher.cs
- DatePicker.cs
- KoreanCalendar.cs
- CanonicalFontFamilyReference.cs
- AsyncWaitHandle.cs
- SqlMetaData.cs
- StatusBarDesigner.cs
- NullableFloatAverageAggregationOperator.cs
- SqlMultiplexer.cs
- TypedMessageConverter.cs
- Single.cs
- SchemaMapping.cs
- EventWaitHandle.cs
- MatrixTransform3D.cs
- ComponentConverter.cs
- BamlResourceSerializer.cs
- RegexEditorDialog.cs
- ContextStaticAttribute.cs
- listitem.cs
- SqlBuffer.cs
- SafeFileMapViewHandle.cs
- DataObjectPastingEventArgs.cs
- ProfileService.cs
- HMACMD5.cs
- Process.cs
- HtmlInputSubmit.cs
- COM2ExtendedTypeConverter.cs
- DiagnosticsElement.cs
- NotifyIcon.cs
- AnnotationComponentChooser.cs
- XmlCharacterData.cs
- FixedSOMTableCell.cs
- TransformValueSerializer.cs
- BindingBase.cs
- Message.cs
- ValidationRuleCollection.cs
- TrackingDataItem.cs
- behaviorssection.cs
- XmlDocumentFragment.cs
- ParameterBuilder.cs
- ProtocolInformationReader.cs
- TimeSpanConverter.cs
- UIElement3DAutomationPeer.cs
- SqlXml.cs
- AnnotationAuthorChangedEventArgs.cs
- RemotingService.cs
- FileDialog_Vista.cs
- GlobalAllocSafeHandle.cs
- CursorConverter.cs
- HTTPRemotingHandler.cs
- BinaryConverter.cs
- Axis.cs
- TextLineResult.cs
- CompilerState.cs
- UnsignedPublishLicense.cs
- ManualResetEvent.cs
- CompensateDesigner.cs
- DetailsViewPageEventArgs.cs
- RenderOptions.cs
- UnsafeNetInfoNativeMethods.cs
- AnonymousIdentificationSection.cs
- DataFormats.cs
- BindingWorker.cs
- CompareValidator.cs
- OdbcCommand.cs
- SafeFileMapViewHandle.cs
- DecimalKeyFrameCollection.cs
- LongSumAggregationOperator.cs