Represents a wrapper for DownloadDataCompletedEventArgs
Inheritance: System.ComponentModel.AsyncCompletedEventArgs
コード例 #1
0
        public WhichThrowsGraphExceptionThen()
        {
            this.facebookClient = new FacebookClient();

            var tempState = new WebClientStateContainer
                                {
                                    Method = this.httpMethod,
                                    RequestUri = new Uri(this.requestUrl),
                                };

            this.downloadDataCompletedEventArgs =
                new DownloadDataCompletedEventArgsWrapper(
                    WebClientFakes.GetFakeWebException(jsonResult), false, tempState, null);
        }
コード例 #2
0
        public ThrowsRestApiErrorThen()
        {
            this.facebookClient = new FacebookClient();

            var tempState = new WebClientStateContainer
                                {
                                    Method = this.httpMethod,
                                    RequestUri = new Uri(this.requestUrl),
                                };

            this.downloadDataCompletedEventArgs =
                new DownloadDataCompletedEventArgsWrapper(
                    null, false, tempState, System.Text.Encoding.UTF8.GetBytes(jsonResult));
        }
コード例 #3
0
        internal void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgsWrapper e)
        {
            string json = null;

            if (e.Error == null && e.Result != null)
            {
                json = Encoding.UTF8.GetString(e.Result, 0, e.Result.Length);
            }

            HttpMethod method;
            var        args = GetApiEventArgs(e, json, out method);

            OnGetCompleted(args);
        }
コード例 #4
0
        internal void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgsWrapper e, Func<string, string> processResponseString, Action<object, FacebookApiEventArgs> onDownloadComplete)
        {
            Contract.Requires(onDownloadComplete != null);

            // var userState = (WebClientStateContainer)e.UserState;

            string json = null;

            if (e.Error == null && e.Result != null)
            {
                json = Encoding.UTF8.GetString(e.Result, 0, e.Result.Length);

                if (processResponseString != null)
                {
                    // make the result json
                    json = processResponseString(json);
                }
            }

            HttpMethod method;
            var args = GetApiEventArgs(e, json, out method);

            /*
             * use onDownloadComplete instead, so don't need to do string compare

            if (userState.RequestUri.AbsolutePath.StartsWith("/oauth/access_token") && GetApplicationAccessTokenCompleted != null)
            {
                GetApplicationAccessTokenCompleted(this, args);
            }

             */

            onDownloadComplete(this, args);
        }