Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Web / System / Web / Services / Protocols / SoapExtensionStream.cs / 1305376 / SoapExtensionStream.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Protocols { using System; using System.IO; using System.Web.Services; internal class SoapExtensionStream : Stream { internal Stream innerStream; bool hasWritten = false; bool streamReady; internal SoapExtensionStream() { } private bool EnsureStreamReady() { if (streamReady) return true; throw new InvalidOperationException(Res.GetString(Res.WebBadStreamState)); } public override bool CanRead { get { EnsureStreamReady(); return innerStream.CanRead; } } public override bool CanSeek { get { EnsureStreamReady(); return innerStream.CanSeek; } } public override bool CanWrite { get { EnsureStreamReady(); return innerStream.CanWrite; } } internal bool HasWritten { get { return this.hasWritten; } } public override long Length { get { EnsureStreamReady(); return innerStream.Length; } } public override long Position { get { EnsureStreamReady(); return innerStream.Position; } set { EnsureStreamReady(); this.hasWritten = true; innerStream.Position = value; } } protected override void Dispose(bool disposing) { try { if (disposing) { EnsureStreamReady(); this.hasWritten = true; innerStream.Close(); } } finally { base.Dispose(disposing); } } public override void Flush() { EnsureStreamReady(); this.hasWritten = true; innerStream.Flush(); } public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) { EnsureStreamReady(); return innerStream.BeginRead(buffer, offset, count, callback, state); } public override int EndRead(IAsyncResult asyncResult) { EnsureStreamReady(); return innerStream.EndRead(asyncResult); } public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) { EnsureStreamReady(); this.hasWritten = true; return innerStream.BeginWrite(buffer, offset, count, callback, state); } public override void EndWrite(IAsyncResult asyncResult) { EnsureStreamReady(); this.hasWritten = true; innerStream.EndWrite(asyncResult); } public override long Seek(long offset, SeekOrigin origin) { EnsureStreamReady(); return innerStream.Seek(offset, origin); } public override void SetLength(long value) { EnsureStreamReady(); innerStream.SetLength(value); } public override int Read(byte[] buffer, int offset, int count) { EnsureStreamReady(); return innerStream.Read(buffer, offset, count); } public override int ReadByte() { EnsureStreamReady(); return innerStream.ReadByte(); } public override void Write(byte[] buffer, int offset, int count) { EnsureStreamReady(); this.hasWritten = true; innerStream.Write(buffer, offset, count); } public override void WriteByte(byte value) { EnsureStreamReady(); this.hasWritten = true; innerStream.WriteByte(value); } internal void SetInnerStream(Stream stream) { innerStream = stream; this.hasWritten = false; } internal void SetStreamReady() { streamReady = true; } } } // 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
- RichTextBox.cs
- ExclusiveTcpTransportManager.cs
- Material.cs
- BinaryReader.cs
- SearchForVirtualItemEventArgs.cs
- Library.cs
- MainMenu.cs
- XmlDataImplementation.cs
- MDIWindowDialog.cs
- XmlCustomFormatter.cs
- ObjectDataSource.cs
- AssertSection.cs
- ClientApiGenerator.cs
- StrongTypingException.cs
- _DigestClient.cs
- InputLangChangeEvent.cs
- NestedContainer.cs
- EntityTypeBase.cs
- Ops.cs
- HttpClientChannel.cs
- TextBoxAutomationPeer.cs
- XmlDataSourceNodeDescriptor.cs
- AmbientLight.cs
- Codec.cs
- SafeHGlobalHandleCritical.cs
- SwitchLevelAttribute.cs
- RenderCapability.cs
- HuffCodec.cs
- ClickablePoint.cs
- WebPartConnectionsDisconnectVerb.cs
- Binding.cs
- ValuePattern.cs
- StrongNamePublicKeyBlob.cs
- PolygonHotSpot.cs
- ArrangedElement.cs
- PersonalizationProviderCollection.cs
- AppSettingsExpressionEditor.cs
- TraceXPathNavigator.cs
- BinaryConverter.cs
- DelegateHelpers.cs
- DocumentPageViewAutomationPeer.cs
- WizardPanel.cs
- LocalTransaction.cs
- EncryptedPackageFilter.cs
- SystemUnicastIPAddressInformation.cs
- SkinBuilder.cs
- TraceHandlerErrorFormatter.cs
- COM2Enum.cs
- OneWayChannelFactory.cs
- CaseCqlBlock.cs
- SHA1Managed.cs
- DataColumnMappingCollection.cs
- Span.cs
- CatalogZoneBase.cs
- DetailsViewInsertEventArgs.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- DragDrop.cs
- SqlLiftWhereClauses.cs
- ErrorFormatter.cs
- SectionInformation.cs
- DataGridViewMethods.cs
- ManagedWndProcTracker.cs
- TraceListener.cs
- Hashtable.cs
- ApplicationBuildProvider.cs
- CodeTypeDeclarationCollection.cs
- InternalPermissions.cs
- TextDocumentView.cs
- LocalizabilityAttribute.cs
- WebZone.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- ListBox.cs
- HtmlTableRowCollection.cs
- PeerCustomResolverElement.cs
- SafeRightsManagementHandle.cs
- XPathMultyIterator.cs
- EditorAttribute.cs
- InternalTransaction.cs
- ColorContext.cs
- OdbcConnectionStringbuilder.cs
- WebPartTransformerCollection.cs
- _Events.cs
- MetadataUtil.cs
- ConnectionsZone.cs
- TextModifier.cs
- XmlCustomFormatter.cs
- TypeSystem.cs
- DESCryptoServiceProvider.cs
- DataStorage.cs
- ActivityWithResultWrapper.cs
- CodeTypeReferenceCollection.cs
- RefreshEventArgs.cs
- Zone.cs
- SchemaImporterExtensionsSection.cs
- DBDataPermissionAttribute.cs
- Matrix.cs
- Quad.cs
- TextContainer.cs
- WindowsFormsHostPropertyMap.cs
- Int32AnimationBase.cs