Code:
                         / 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / MS / Internal / IO / Packaging / CompoundFile / StreamWithDictionary.cs / 1305600 / StreamWithDictionary.cs
                        
                        
                            //------------------------------------------------------------------------------ 
//
// 
//    Copyright (C) Microsoft Corporation.  All rights reserved.
//   
//
// Description: 
//   The object for wrapping a data stream and its associated context 
//   information dictionary.
// 
// History:
//  07/05/2002: RogerCh: Initial implementation.
//  05/20/2003: RogerCh: Ported to WCP tree.
// 
//-----------------------------------------------------------------------------
 
using System; 
using System.Collections;
using System.IO; 
namespace MS.Internal.IO.Packaging.CompoundFile
{
    internal class StreamWithDictionary : Stream, IDictionary 
    {
        Stream baseStream; 
        IDictionary baseDictionary; 
        private bool _disposed;         // keep track of if we are disposed
 
        internal StreamWithDictionary( Stream wrappedStream, IDictionary wrappedDictionary )
        {
            baseStream = wrappedStream;
            baseDictionary = wrappedDictionary; 
        }
 
        /*************************************************************************/ 
        // Stream members
        public override bool CanRead { get{ return !_disposed && baseStream.CanRead; }} 
        public override bool CanSeek { get { return !_disposed && baseStream.CanSeek; } }
        public override bool CanWrite { get { return !_disposed && baseStream.CanWrite; } }
        public override long Length
        { 
            get
            { 
                CheckDisposed(); 
                return baseStream.Length;
            } 
        }
        public override long Position
        { 
            get
            { 
                CheckDisposed(); 
                return baseStream.Position;
            } 
            set
            {
                CheckDisposed();
                baseStream.Position = value; 
            }
        } 
 
        public override void Flush()
        { 
            CheckDisposed();
            baseStream.Flush();
        }
 
        public override long Seek( long offset, SeekOrigin origin )
        { 
            CheckDisposed(); 
            return baseStream.Seek(offset, origin);
        } 
        public override void SetLength( long newLength )
        {
            CheckDisposed(); 
            baseStream.SetLength(newLength);
        } 
 
        public override int Read( byte[] buffer, int offset, int count )
        { 
            CheckDisposed();
            return baseStream.Read(buffer, offset, count);
        }
 
        public override void Write( byte[] buffer, int offset, int count )
        { 
            CheckDisposed(); 
            baseStream.Write(buffer, offset, count);
        } 
        //-----------------------------------------------------
        //
        //  Protected Methods 
        //
        //----------------------------------------------------- 
        ///  
        /// Dispose(bool)
        ///   
        /// 
        protected override void Dispose(bool disposing)
        {
            try 
            {
                if (disposing && !_disposed) 
                { 
                    _disposed = true;
                    baseStream.Close(); 
                }
            }
            finally
            { 
                base.Dispose(disposing);
            } 
        } 
        /*************************************************************************/ 
        // IDictionary members
        bool IDictionary.Contains( object key )
        {
            CheckDisposed(); 
            return baseDictionary.Contains(key);
        } 
 
        void IDictionary.Add( object key, object val )
        { 
            CheckDisposed();
            baseDictionary.Add(key, val);
        }
 
        void IDictionary.Clear()
        { 
            CheckDisposed(); 
            baseDictionary.Clear();
        } 
        IDictionaryEnumerator IDictionary.GetEnumerator()
        {
            CheckDisposed(); 
            // IDictionary.GetEnumerator vs. IEnumerable.GetEnumerator?
            return ((IDictionary)baseDictionary).GetEnumerator(); 
        } 
        void IDictionary.Remove( object key ) 
        {
            CheckDisposed();
            baseDictionary.Remove(key);
        } 
        object IDictionary.this[ object index ] 
        { 
            get
            { 
                CheckDisposed();
                return baseDictionary[index];
            }
            set 
            {
                CheckDisposed(); 
                baseDictionary[index] = value; 
            }
        } 
        ICollection IDictionary.Keys
        {
            get 
            {
                CheckDisposed(); 
                return baseDictionary.Keys; 
            }
        } 
        ICollection IDictionary.Values
        {
            get 
            {
                CheckDisposed(); 
                return baseDictionary.Values; 
            }
        } 
        bool IDictionary.IsReadOnly
        {
            get 
            {
                CheckDisposed(); 
                return baseDictionary.IsReadOnly; 
            }
        } 
        bool IDictionary.IsFixedSize
        {
            get 
            {
                CheckDisposed(); 
                return baseDictionary.IsFixedSize; 
            }
        } 
        /*************************************************************************/
        // ICollection methods
 
        void ICollection.CopyTo( Array array, int index )
        { 
            CheckDisposed(); 
            ((ICollection)baseDictionary).CopyTo(array, index);
        } 
        int ICollection.Count
        {
            get 
            {
                CheckDisposed(); 
                return ((ICollection)baseDictionary).Count; 
            }
        } 
        object ICollection.SyncRoot
        {
            get 
            {
                CheckDisposed(); 
                return ((ICollection)baseDictionary).SyncRoot; 
            }
        } 
        bool ICollection.IsSynchronized
        {
            get 
            {
                CheckDisposed(); 
                return ((ICollection)baseDictionary).IsSynchronized; 
            }
        } 
        /*************************************************************************/
        // IEnumerable method
 
        IEnumerator IEnumerable.GetEnumerator()
        { 
            CheckDisposed(); 
            return ((IEnumerable)baseDictionary).GetEnumerator();
        } 
        /// 
        /// Disposed - were we disposed? Offer this to DataSpaceManager so it can do smart flushing
        ///   
        /// 
//    Copyright (C) Microsoft Corporation.  All rights reserved.
//   
//
// Description: 
//   The object for wrapping a data stream and its associated context 
//   information dictionary.
// 
// History:
//  07/05/2002: RogerCh: Initial implementation.
//  05/20/2003: RogerCh: Ported to WCP tree.
// 
//-----------------------------------------------------------------------------
 
using System; 
using System.Collections;
using System.IO; 
namespace MS.Internal.IO.Packaging.CompoundFile
{
    internal class StreamWithDictionary : Stream, IDictionary 
    {
        Stream baseStream; 
        IDictionary baseDictionary; 
        private bool _disposed;         // keep track of if we are disposed
 
        internal StreamWithDictionary( Stream wrappedStream, IDictionary wrappedDictionary )
        {
            baseStream = wrappedStream;
            baseDictionary = wrappedDictionary; 
        }
 
        /*************************************************************************/ 
        // Stream members
        public override bool CanRead { get{ return !_disposed && baseStream.CanRead; }} 
        public override bool CanSeek { get { return !_disposed && baseStream.CanSeek; } }
        public override bool CanWrite { get { return !_disposed && baseStream.CanWrite; } }
        public override long Length
        { 
            get
            { 
                CheckDisposed(); 
                return baseStream.Length;
            } 
        }
        public override long Position
        { 
            get
            { 
                CheckDisposed(); 
                return baseStream.Position;
            } 
            set
            {
                CheckDisposed();
                baseStream.Position = value; 
            }
        } 
 
        public override void Flush()
        { 
            CheckDisposed();
            baseStream.Flush();
        }
 
        public override long Seek( long offset, SeekOrigin origin )
        { 
            CheckDisposed(); 
            return baseStream.Seek(offset, origin);
        } 
        public override void SetLength( long newLength )
        {
            CheckDisposed(); 
            baseStream.SetLength(newLength);
        } 
 
        public override int Read( byte[] buffer, int offset, int count )
        { 
            CheckDisposed();
            return baseStream.Read(buffer, offset, count);
        }
 
        public override void Write( byte[] buffer, int offset, int count )
        { 
            CheckDisposed(); 
            baseStream.Write(buffer, offset, count);
        } 
        //-----------------------------------------------------
        //
        //  Protected Methods 
        //
        //----------------------------------------------------- 
        ///  
        /// Dispose(bool)
        ///   
        /// 
        protected override void Dispose(bool disposing)
        {
            try 
            {
                if (disposing && !_disposed) 
                { 
                    _disposed = true;
                    baseStream.Close(); 
                }
            }
            finally
            { 
                base.Dispose(disposing);
            } 
        } 
        /*************************************************************************/ 
        // IDictionary members
        bool IDictionary.Contains( object key )
        {
            CheckDisposed(); 
            return baseDictionary.Contains(key);
        } 
 
        void IDictionary.Add( object key, object val )
        { 
            CheckDisposed();
            baseDictionary.Add(key, val);
        }
 
        void IDictionary.Clear()
        { 
            CheckDisposed(); 
            baseDictionary.Clear();
        } 
        IDictionaryEnumerator IDictionary.GetEnumerator()
        {
            CheckDisposed(); 
            // IDictionary.GetEnumerator vs. IEnumerable.GetEnumerator?
            return ((IDictionary)baseDictionary).GetEnumerator(); 
        } 
        void IDictionary.Remove( object key ) 
        {
            CheckDisposed();
            baseDictionary.Remove(key);
        } 
        object IDictionary.this[ object index ] 
        { 
            get
            { 
                CheckDisposed();
                return baseDictionary[index];
            }
            set 
            {
                CheckDisposed(); 
                baseDictionary[index] = value; 
            }
        } 
        ICollection IDictionary.Keys
        {
            get 
            {
                CheckDisposed(); 
                return baseDictionary.Keys; 
            }
        } 
        ICollection IDictionary.Values
        {
            get 
            {
                CheckDisposed(); 
                return baseDictionary.Values; 
            }
        } 
        bool IDictionary.IsReadOnly
        {
            get 
            {
                CheckDisposed(); 
                return baseDictionary.IsReadOnly; 
            }
        } 
        bool IDictionary.IsFixedSize
        {
            get 
            {
                CheckDisposed(); 
                return baseDictionary.IsFixedSize; 
            }
        } 
        /*************************************************************************/
        // ICollection methods
 
        void ICollection.CopyTo( Array array, int index )
        { 
            CheckDisposed(); 
            ((ICollection)baseDictionary).CopyTo(array, index);
        } 
        int ICollection.Count
        {
            get 
            {
                CheckDisposed(); 
                return ((ICollection)baseDictionary).Count; 
            }
        } 
        object ICollection.SyncRoot
        {
            get 
            {
                CheckDisposed(); 
                return ((ICollection)baseDictionary).SyncRoot; 
            }
        } 
        bool ICollection.IsSynchronized
        {
            get 
            {
                CheckDisposed(); 
                return ((ICollection)baseDictionary).IsSynchronized; 
            }
        } 
        /*************************************************************************/
        // IEnumerable method
 
        IEnumerator IEnumerable.GetEnumerator()
        { 
            CheckDisposed(); 
            return ((IEnumerable)baseDictionary).GetEnumerator();
        } 
        /// 
        /// Disposed - were we disposed? Offer this to DataSpaceManager so it can do smart flushing
        ///   
        /// 
                        
                        
                        
                    Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SapiRecoContext.cs
- RsaKeyIdentifierClause.cs
- CombinedTcpChannel.cs
- TypeConstant.cs
- TextBox.cs
- DBConcurrencyException.cs
- ExceptionAggregator.cs
- CleanUpVirtualizedItemEventArgs.cs
- AutomationAttributeInfo.cs
- LayoutEditorPart.cs
- TypeNameConverter.cs
- GradientStop.cs
- CellTreeNodeVisitors.cs
- BaseDataBoundControl.cs
- SplitContainer.cs
- OdbcError.cs
- GeneralTransform3D.cs
- InternalConfigEventArgs.cs
- AppModelKnownContentFactory.cs
- MethodBody.cs
- EventManager.cs
- MemberHolder.cs
- TextProperties.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- _Connection.cs
- RoleService.cs
- Validator.cs
- HtmlImageAdapter.cs
- GeometryCollection.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- ParseHttpDate.cs
- TextViewSelectionProcessor.cs
- _Connection.cs
- Section.cs
- MethodBuilder.cs
- sqlmetadatafactory.cs
- Matrix3D.cs
- TargetInvocationException.cs
- XmlMapping.cs
- VirtualPath.cs
- XhtmlTextWriter.cs
- SqlConnectionPoolGroupProviderInfo.cs
- SafeEventLogReadHandle.cs
- EntityContainer.cs
- SqlFormatter.cs
- NameService.cs
- WebBrowserProgressChangedEventHandler.cs
- IteratorDescriptor.cs
- SqlNodeTypeOperators.cs
- Matrix3DValueSerializer.cs
- Win32Native.cs
- TransformerInfoCollection.cs
- BoundsDrawingContextWalker.cs
- FileCodeGroup.cs
- CopyOnWriteList.cs
- TimelineGroup.cs
- StateMachine.cs
- RelatedEnd.cs
- UnsafeNativeMethods.cs
- InputScopeAttribute.cs
- PagerSettings.cs
- WebBrowserNavigatingEventHandler.cs
- EventMappingSettings.cs
- MultiSelectRootGridEntry.cs
- ContactManager.cs
- DataGridHelper.cs
- PersonalizationProvider.cs
- MimeMultiPart.cs
- EntityDataSourceView.cs
- HeaderCollection.cs
- DetailsViewDeletedEventArgs.cs
- EntityKeyElement.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- OperationDescription.cs
- ChannelServices.cs
- InternalsVisibleToAttribute.cs
- DataSourceSelectArguments.cs
- BooleanFunctions.cs
- ExpressionBinding.cs
- PointUtil.cs
- SecurityIdentifierConverter.cs
- AttributeQuery.cs
- WorkflowItemPresenter.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- ColorContext.cs
- FixedSOMGroup.cs
- Error.cs
- SoapTypeAttribute.cs
- MimeMapping.cs
- HttpNamespaceReservationInstallComponent.cs
- StylusPlugin.cs
- RepeatEnumerable.cs
- DynamicResourceExtension.cs
- OleDbReferenceCollection.cs
- UidManager.cs
- Odbc32.cs
- Oid.cs
- X509Chain.cs
- WebServiceTypeData.cs
- EntityDataSourceStatementEditor.cs