Ejemplo n.º 1
0
        /// <summary>
        /// Makes a async request to the Facebook server.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void ApiAsync(IDictionary <string, object> parameters, FacebookAsyncCallback callback, object state)
        {
            Contract.Requires(callback != null);
            Contract.Requires(parameters != null);

            this.ApiAsync(callback, state, null, parameters, HttpMethod.Get);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Makes a async request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void ApiAsync(string path, FacebookAsyncCallback callback, object state)
        {
            Contract.Requires(callback != null);
            Contract.Requires(!String.IsNullOrEmpty(path));

            this.ApiAsync(callback, state, path, null, HttpMethod.Get);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Makes a async request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void ApiAsync(string path, IDictionary <string, object> parameters, FacebookAsyncCallback callback, object state)
        {
            Contract.Requires(callback != null);
            Contract.Requires(!(String.IsNullOrEmpty(path) && parameters == null));

            this.ApiAsync(callback, state, path, parameters, HttpMethod.Get);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Makes an asynchronous GET request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void GetAsync(string path, FacebookAsyncCallback callback)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            ApiAsync(path, null, HttpMethod.Get, callback, null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Makes an asynchronous GET request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void GetAsync <T>(string path, FacebookAsyncCallback <T> callback, object state)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            ApiAsync <T>(path, null, HttpMethod.Get, callback, state);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Makes an asynchronous GET request to the Facebook server.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void GetAsync <T>(IDictionary <string, object> parameters, FacebookAsyncCallback <T> callback)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            ApiAsync <T>(null, parameters, HttpMethod.Get, callback, null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Makes an asynchronous POST request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void PostAsync(string path, IDictionary <string, object> parameters, FacebookAsyncCallback callback, object state)
        {
            if (string.IsNullOrEmpty(path) && parameters == null)
            {
                throw new ArgumentException("At least path or parameters must be defined.");
            }

            ApiAsync(path, parameters, HttpMethod.Post, callback, state);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Makes an asynchronous POST request to the Facebook server.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void PostAsync(IDictionary <string, object> parameters, FacebookAsyncCallback callback, object state)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            ApiAsync(null, parameters, HttpMethod.Post, callback, state);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Makes an asynchronous POST request to the Facebook server.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void PostAsync(object parameters, FacebookAsyncCallback callback)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PostAsync(FacebookUtils.ToDictionary(parameters), callback, null);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Makes an asynchronous POST request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void PostAsync(string path, object parameters, FacebookAsyncCallback callback)
        {
            if (string.IsNullOrEmpty(path) && parameters == null)
            {
                throw new ArgumentException("At least path or parameters must be defined.");
            }

            PostAsync(path, FacebookUtils.ToDictionary(parameters), callback, null);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Makes an asynchronous DELETE request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void DeleteAsync(string path, FacebookAsyncCallback callback, object state)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            ApiAsync(path, null, HttpMethod.Delete, callback, state);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Executes a FQL query asynchronously.
        /// </summary>
        /// <param name="fql">
        /// The FQL query.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void QueryAsync(string fql, FacebookAsyncCallback callback, object state)
        {
            Contract.Requires(!String.IsNullOrEmpty(fql));

            var parameters = new Dictionary <string, object>();

            parameters["query"]  = fql;
            parameters["method"] = "fql.query";

            GetAsync(parameters, callback, state);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Executes a FQL query asynchronously.
        /// </summary>
        /// <param name="fql">
        /// The FQL query.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void QueryAsync(string fql, FacebookAsyncCallback callback, object state)
        {
            if (string.IsNullOrEmpty(fql))
            {
                throw new ArgumentNullException("fql");
            }

            var parameters = new Dictionary <string, object>();

            parameters["query"]  = fql;
            parameters["method"] = "fql.query";

            GetAsync(parameters, callback, state);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Executes a FQL query asynchronously.
        /// </summary>
        /// <param name="fql">
        /// The FQL query.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void QueryAsync(string[] fql, FacebookAsyncCallback callback, object state)
        {
            Contract.Requires(fql != null);
            Contract.Requires(fql.Length > 0);

            var queryDict = new Dictionary <string, object>();

            for (int i = 0; i < fql.Length; i++)
            {
                queryDict.Add(string.Concat("query", i), fql[i]);
            }

            var parameters = new Dictionary <string, object>();

            parameters["queries"] = queryDict;
            parameters["method"]  = "fql.multiquery";
            this.GetAsync(parameters, callback, state);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Executes a FQL query asynchronously.
        /// </summary>
        /// <param name="fql">
        /// The FQL query.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void QueryAsync(string[] fql, FacebookAsyncCallback callback, object state)
        {
            if (fql == null)
            {
                throw new ArgumentNullException("fql");
            }
            if (fql.Length == 0)
            {
                throw new ArgumentException("At least one fql query required.", "fql");
            }

            var queryDict = new Dictionary <string, object>();

            for (int i = 0; i < fql.Length; i++)
            {
                queryDict.Add(string.Concat("query", i), fql[i]);
            }

            var parameters = new Dictionary <string, object>();

            parameters["queries"] = queryDict;
            parameters["method"]  = "fql.multiquery";
            this.GetAsync(parameters, callback, state);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Makes an asynchronous POST request to the Facebook server.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void PostAsync(IDictionary <string, object> parameters, FacebookAsyncCallback callback, object state)
        {
            Contract.Requires(parameters != null);

            ApiAsync(null, parameters, HttpMethod.Post, callback, state);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Makes a async request to the Facebook server.
 /// </summary>
 /// <param name="path">
 /// The path.
 /// </param>
 /// <param name="parameters">
 /// The parameters.
 /// </param>
 /// <param name="httpMethod">
 /// The http Method.
 /// </param>
 /// <param name="callback">
 /// The callback.
 /// </param>
 /// <param name="state">
 /// The state.
 /// </param>
 public virtual void ApiAsync <T>(string path, IDictionary <string, object> parameters, HttpMethod httpMethod, FacebookAsyncCallback <T> callback, object state)
 {
     ApiAsync(
         path,
         FacebookWebClient.AddReturnSslResourceIfRequired(parameters, IsSecureConnection),
         httpMethod,
         ar =>
     {
         if (callback != null)
         {
             callback(new FacebookAsyncResult <T>(ar.Result, ar.AsyncState, ar.AsyncWaitHandle, ar.CompletedSynchronously, ar.IsCompleted, ar.Error));
         }
     },
         state);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Makes an asynchronous DELETE request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void DeleteAsync(string path, FacebookAsyncCallback callback, object state)
        {
            Contract.Requires(!String.IsNullOrEmpty(path));

            ApiAsync(path, null, HttpMethod.Delete, callback, state);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Makes an asynchronous GET request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void GetAsync(string path, FacebookAsyncCallback callback)
        {
            Contract.Requires(!String.IsNullOrEmpty(path));

            ApiAsync(path, null, HttpMethod.Get, callback, null);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Makes an asynchronous GET request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void GetAsync <T>(string path, FacebookAsyncCallback <T> callback, object state)
        {
            Contract.Requires(!String.IsNullOrEmpty(path));

            ApiAsync <T>(path, null, HttpMethod.Get, callback, state);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Makes an asynchronous GET request to the Facebook server.
        /// </summary>
        /// <typeparam name="T">
        /// </typeparam>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void GetAsync <T>(string path, IDictionary <string, object> parameters, FacebookAsyncCallback <T> callback)
        {
            Contract.Requires(!(String.IsNullOrEmpty(path) && parameters == null));

            ApiAsync <T>(path, parameters, HttpMethod.Get, callback, null);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Makes an asynchronous GET request to the Facebook server.
        /// </summary>
        /// <typeparam name="T">
        /// </typeparam>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void GetAsync <T>(string path, IDictionary <string, object> parameters, FacebookAsyncCallback <T> callback)
        {
            if (string.IsNullOrEmpty(path) && parameters == null)
            {
                throw new ArgumentException("At least path or parameters must be defined.");
            }

            ApiAsync <T>(path, parameters, HttpMethod.Get, callback, null);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Makes an asynchronous GET request to the Facebook server.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void GetAsync <T>(IDictionary <string, object> parameters, FacebookAsyncCallback <T> callback)
        {
            Contract.Requires(parameters != null);

            ApiAsync <T>(null, parameters, HttpMethod.Get, callback, null);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Makes an asynchronous POST request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="state">
        /// The state.
        /// </param>
        public void PostAsync(string path, IDictionary <string, object> parameters, FacebookAsyncCallback callback, object state)
        {
            Contract.Requires(!(String.IsNullOrEmpty(path) && parameters == null));

            ApiAsync(path, parameters, HttpMethod.Post, callback, state);
        }
Ejemplo n.º 25
0
        internal protected virtual void ApiAsync(string path, IDictionary <string, object> parameters, HttpMethod httpMethod, FacebookAsyncCallback callback, object userToken)
        {
            var facebookClient = GetFacebookClient();

            if (callback != null)
            {
                switch (httpMethod)
                {
                case HttpMethod.Get:
                    facebookClient.GetCompleted += (o, e) => callback(new FacebookAsyncResult(e.GetResultData(), e.UserState, null, false, true, e.Error as FacebookApiException));
                    break;

                case HttpMethod.Post:
                    facebookClient.PostCompleted += (o, e) => callback(new FacebookAsyncResult(e.GetResultData(), e.UserState, null, false, true, e.Error as FacebookApiException));
                    break;

                case HttpMethod.Delete:
                    facebookClient.DeleteCompleted += (o, e) => callback(new FacebookAsyncResult(e.GetResultData(), e.UserState, null, false, true, e.Error as FacebookApiException));
                    break;

                default:
                    throw new ArgumentOutOfRangeException("httpMethod");
                }
            }

            facebookClient.ApiAsync(path, parameters, httpMethod, userToken);
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Executes a FQL multiquery asynchronously.
 /// </summary>
 /// <param name="fql">
 /// The FQL queries.
 /// </param>
 /// <param name="callback">
 /// The callback.
 /// </param>
 public void QueryAsync(string[] fql, FacebookAsyncCallback callback)
 {
     this.QueryAsync(fql, callback, null);
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Makes an asynchronous POST request to the Facebook server.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void PostAsync(object parameters, FacebookAsyncCallback callback)
        {
            Contract.Requires(parameters != null);

            PostAsync(FacebookUtils.ToDictionary(parameters), callback, null);
        }
Ejemplo n.º 28
0
 internal protected virtual void ApiAsync <T>(string path, IDictionary <string, object> parameters, HttpMethod httpMethod, FacebookAsyncCallback <T> callback, object state)
 {
     ApiAsync(
         path,
         parameters,
         httpMethod,
         ar =>
     {
         if (callback != null)
         {
             callback(new FacebookAsyncResult <T>(ar.Result, ar.AsyncState, ar.AsyncWaitHandle, ar.CompletedSynchronously, ar.IsCompleted, ar.Error));
         }
     },
         state);
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Makes an asynchronous POST request to the Facebook server.
        /// </summary>
        /// <param name="path">
        /// The resource path.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void PostAsync(string path, object parameters, FacebookAsyncCallback callback)
        {
            Contract.Requires(!(String.IsNullOrEmpty(path) && parameters == null));

            PostAsync(path, FacebookUtils.ToDictionary(parameters), callback, null);
        }