Beispiel #1
0
        public void when_disposing_more_than_once_nothing_happens()
        {
            var ms = new UnmanagedStream(SHCreateMemStream(), true);

            ms.Dispose();

            Action action = () => ms.Dispose();

            action.ShouldNotThrow <ObjectDisposedException>();
        }
Beispiel #2
0
        public void when_accessing_members_after_disposed_throws_up()
        {
            var ms = new UnmanagedStream(SHCreateMemStream(), true);

            ms.Dispose();

            Action action;

            action = () => ms.Flush();
            action.ShouldThrow <ObjectDisposedException>();

            action = () => new Func <long>(() => ms.Length).Invoke();
            action.ShouldThrow <ObjectDisposedException>();

            action = () => new Func <long>(() => ms.Position).Invoke();
            action.ShouldThrow <ObjectDisposedException>();

            action = () => ms.ReadByte();
            action.ShouldThrow <ObjectDisposedException>();

            action = () => ms.WriteByte(0);
            action.ShouldThrow <ObjectDisposedException>();

            action = () => ms.SetLength(0);
            action.ShouldThrow <ObjectDisposedException>();
        }
Beispiel #3
0
 internal void RepsonseEnd(ref UnmanagedStream responseStream)
 {
     if (SocketIdentity == Socket.Identity)
     {
         HttpResponse.SetBody(responseStream);
         responseStream.Dispose();
         ResponseStream = responseStream;
         responseStream = null;
         SocketResponse(ref PageResponse);
     }
 }
            protected override void Dispose(bool disposing)
            {
                base.Dispose(disposing);

                if (disposing)
                {
                    UnmanagedStream.Dispose();
                }

                Cleanup(Result);
            }
Beispiel #5
0
        /// <summary>
        /// WEB 调用处理
        /// </summary>
        /// <param name="call"></param>
        /// <returns></returns>
        private unsafe bool callSynchronize(AutoCSer.WebView.CallBase call)
        {
            //if (call.IsAsynchronous) return this.call(callInfo.MethodIndex, call);
            UnmanagedStream responseStream = null;
            long            identity       = call.SocketIdentity;

            AutoCSer.Memory.Pointer buffer = UnmanagedPool.Default.GetPointer();
            try
            {
                responseStream = call.GetResponseStream(ref buffer);
                return(this.call(call, ref responseStream));
            }
            finally
            {
                UnmanagedPool.Default.PushOnly(ref buffer);
                if (responseStream != null)
                {
                    responseStream.Dispose();
                    call.ResponseStream = responseStream;
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     stream.Dispose();
 }
Beispiel #7
0
 /// <summary>
 /// 释放数据流
 /// </summary>
 public void Dispose()
 {
     stream.Dispose();
     stream = null;
 }