Пример #1
0
 public override void Write(byte[] buffer, int offset, int count)
 {
     this.CheckDisposed("Write");
     MapiStreamWrapper.CallMapi("Write", this, this.session, delegate
     {
         this.mapiStream.Write(buffer, offset, count);
     });
 }
Пример #2
0
 public void UnlockRegion(long offset, long cb, int lockType)
 {
     this.CheckDisposed("UnlockRegion");
     MapiStreamWrapper.CallMapi("UnlockRegion", this, this.session, delegate
     {
         this.mapiStream.UnlockRegion(offset, cb, lockType);
     });
 }
Пример #3
0
 public override void SetLength(long length)
 {
     this.CheckDisposed("SetLength");
     MapiStreamWrapper.CallMapi("SetLength", this, this.session, delegate
     {
         this.mapiStream.SetLength(length);
     });
 }
Пример #4
0
 public override void Flush()
 {
     this.CheckDisposed("Flush");
     MapiStreamWrapper.CallMapi("Flush", this, this.session, delegate
     {
         this.mapiStream.Flush();
     });
 }
Пример #5
0
 protected override void Dispose(bool isDisposing)
 {
     base.Dispose(isDisposing);
     if (isDisposing)
     {
         this.isDisposed = true;
         this.disposeTracker.Dispose();
         MapiStreamWrapper.CallMapi("Dispose", this, this.session, delegate
         {
             this.mapiStream.Dispose();
         });
     }
 }
Пример #6
0
        internal Stream OpenPropertyStream(NativeStorePropertyDefinition propertyDefinition, PropertyOpenMode openMode, bool bufferStream)
        {
            this.CheckDisposed("OpenPropertyStream");
            EnumValidator.AssertValid <PropertyOpenMode>(openMode);
            PropTag           propTag = PropertyTagCache.Cache.PropTagFromPropertyDefinition(this.MapiProp, this.storeSession, propertyDefinition);
            OpenPropertyFlags flags;

            switch (openMode)
            {
            case PropertyOpenMode.ReadOnly:
                flags = OpenPropertyFlags.DeferredErrors;
                break;

            case PropertyOpenMode.Modify:
                flags = OpenPropertyFlags.Modify;
                break;

            case PropertyOpenMode.Create:
                flags = (OpenPropertyFlags.Create | OpenPropertyFlags.Modify);
                break;

            default:
                throw new ArgumentException(ServerStrings.ExInvalidParameter("openMode", 2), "openMode");
            }
            Stream       stream       = null;
            StoreSession storeSession = this.StoreSession;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                stream = new MapiStreamWrapper(this.MapiProp.OpenStream(propTag, flags), this.StoreSession);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExUnableToGetStreamProperty(propertyDefinition.Name), ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::OpenPropertyStream. Failed to open property stream for property {0}, openMode = {1}.", propertyDefinition, openMode),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExUnableToGetStreamProperty(propertyDefinition.Name), ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::OpenPropertyStream. Failed to open property stream for property {0}, openMode = {1}.", propertyDefinition, openMode),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            if (bufferStream)
            {
                stream = new PooledBufferedStream(stream, StorageLimits.Instance.PropertyStreamPageSize);
            }
            return(stream);
        }
Пример #7
0
 public override long Seek(long offset, SeekOrigin origin)
 {
     this.CheckDisposed("Seek");
     return(MapiStreamWrapper.CallMapiWithReturnValue <long>("Seek", this, this.session, () => this.mapiStream.Seek(offset, origin)));
 }
Пример #8
0
 public override int Read(byte[] buffer, int offset, int count)
 {
     this.CheckDisposed("Read");
     return(MapiStreamWrapper.CallMapiWithReturnValue <int>("Read", this, this.session, () => this.mapiStream.Read(buffer, offset, count)));
 }