Inheritance: System.IO.MemoryStream
Beispiel #1
0
        public StubWebRequest()
        {
            this.OnGetContentType = () => this.contentType;
            this.OnSetContentType = value => this.contentType = value;
            this.OnGetHeaders     = () => this.headers = new WebHeaderCollection();
            this.OnSetHeaders     = value => this.headers = value;
            this.OnGetMethod      = () => this.method;
            this.OnSetMethod      = value => this.method = value;
            this.OnGetRequestUri  = () => default(Uri);

            this.OnAbort = () => { };
            this.OnBeginGetRequestStream = (callback, state) => TaskEx.FromResult <object>(null).AsAsyncResult(callback, this);
            this.OnEndGetRequestStream   = asyncResult => this.requestStream = new StubStream();
            this.OnBeginGetResponse      = (callback, state) => TaskEx.FromResult <object>(null).AsAsyncResult(callback, this);
            this.OnEndGetResponse        = asyncResult => this.response = new StubWebResponse();
#if WINRT || WINDOWS_UWP
            this.OnGetRequestStreamAsync = () => Task.Factory.FromAsync(this.OnBeginGetRequestStream, this.OnEndGetRequestStream, null);
            this.OnGetResponseAsync      = () => Task.Factory.FromAsync(this.OnBeginGetResponse, this.OnEndGetResponse, null);
#endif
        }
        public StubWebRequest()
        {
            this.OnGetContentType = () => this.contentType;
            this.OnSetContentType = value => this.contentType = value;
            this.OnGetHeaders = () => this.headers = new WebHeaderCollection();
            this.OnSetHeaders = value => this.headers = value;
            this.OnGetMethod = () => this.method;
            this.OnSetMethod = value => this.method = value;
            this.OnGetRequestUri = () => default(Uri);

            this.OnAbort = () => { };
            this.OnBeginGetRequestStream = (callback, state) => TaskEx.FromResult<object>(null).AsAsyncResult(callback, this);
            this.OnEndGetRequestStream = asyncResult => this.requestStream = new StubStream();
            this.OnBeginGetResponse = (callback, state) => TaskEx.FromResult<object>(null).AsAsyncResult(callback, this);
            this.OnEndGetResponse = asyncResult => this.response = new StubWebResponse();
#if WINRT || WINDOWS_UWP
            this.OnGetRequestStreamAsync = () => Task.Factory.FromAsync(this.OnBeginGetRequestStream, this.OnEndGetRequestStream, null);
            this.OnGetResponseAsync = () => Task.Factory.FromAsync(this.OnBeginGetResponse, this.OnEndGetResponse, null);
#endif
        }