Exemplo n.º 1
0
        /// <summary>
        /// Internal call back when xml deserialization completes.
        /// </summary>
        /// <param name="result"></param>
        protected void XmlResultOperationCompleted(IAsyncResult result)
        {
            AsyncResult ar = (AsyncResult)result;
            FacebookCallCompleted <string> callback = (FacebookCallCompleted <string>)ar.AsyncState;

            if (callback != null)
            {
                callback(ar.Result, ar.AsyncExternalState, ar.Exception);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserializes facebook response object if there is no exception and calls the callback with result
        /// </summary>
        /// <typeparam name="TObject"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="result"></param>
        /// <param name="propName"></param>
        private static void OnFacebookCallCompleted <TObject, TResult>(IAsyncResult result, string propName)
        {
            AsyncResult ar = (AsyncResult)result;
            FacebookCallCompleted <TResult> callback = (FacebookCallCompleted <TResult>)ar.AsyncState;

            if (callback == null)
            {
                return;
            }

            TResult           value     = default(TResult);
            FacebookException exception = ar.Exception;

            if (exception == null)
            {
                try
                {
                    // XML Serialization
                    TObject response = Utilities.DeserializeXML <TObject>(ar.Result);

                    // JSON Serialization
                    //string resultString = FixupJSONString(ar.Result, types[0]);
                    //MethodInfo methodInfo = typeof(Utilities).GetMethod("DeserializeJSONObject").MakeGenericMethod(types[0]);
                    //resultObject = methodInfo.Invoke(null, new object[] { resultString });

                    if (!string.IsNullOrEmpty(propName))
                    {
                        value = (TResult)response.GetType().GetProperty(propName).GetValue(response, null);
                    }
                    else
                    {
                        value = (TResult)(object)response;
                    }
                }
                catch (FacebookException e)
                {
                    exception = e;
                }
            }

            callback(value, ar.AsyncExternalState, exception);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Makes a call to facebook server and returns the result in callback specified
 /// </summary>
 /// <param name="parameterList">parameters that needs to be passed to call.</param>
 /// <param name="useSession">indicator if session should be used or not</param>
 /// <param name="callback">Callback which will be called on response.</param>
 /// <param name="state">User defined object.</param>
 /// <param name="propertyName">The name of the property to retreive.</param>
 public void SendRequestAsync <TObject, TResult>(Dictionary <string, string> parameterList, bool useSession, FacebookCallCompleted <TResult> callback, Object state, string propertyName)
 {
     SendRequestAsync(parameterList, useSession, new AsyncResult(ar => OnFacebookCallCompleted <TObject, TResult>(ar, propertyName), callback, state));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Makes a call to facebook server and returns the result in callback specified
 /// </summary>
 /// <param name="parameterList">parameters that needs to be passed to call.</param>
 /// <param name="callback">Callback which will be called on response.</param>
 /// <param name="state">User defined object.</param>
 /// <param name="propertyName">The name of the property to retreive.</param>
 public void SendRequestAsync <TObject, TResult>(Dictionary <string, string> parameterList, FacebookCallCompleted <TResult> callback, Object state, string propertyName)
 {
     SendRequestAsync <TObject, TResult>(parameterList, true, callback, state, propertyName);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Makes a call to facebook server and returns the result in callback specified
 /// </summary>
 /// <param name="parameterList">parameters that needs to be passed to call</param>
 /// <param name="useSession">indicator if session should be used or not</param>
 /// <param name="callback">Callback which will be called on response.</param>
 /// <param name="state">User defined object</param>
 public void SendRequestAsync <TObject, TResult>(Dictionary <string, string> parameterList, bool useSession, FacebookCallCompleted <TResult> callback, Object state)
 {
     SendRequestAsync <TObject, TResult>(parameterList, useSession, callback, state, "TypedValue");
 }
Exemplo n.º 6
0
        /// <summary>
        /// Makes a call to facebook server and returns the result in callback specified
        /// </summary>
        /// <typeparam name="T">Type of object to which result should be deserialized</typeparam>
        /// <param name="parameterList">parameters that needs to be passed to call</param>
        /// <param name="useSession">whether the call should use the facebook session or not</param>
        /// <param name="callback">Callback which will be called on response.</param>
        /// <param name="state">User defined object</param>
        public void SendRequestAsync <T>(Dictionary <string, string> parameterList, bool useSession, FacebookCallCompleted <T> callback, Object state)
        {
            AsyncResult result = new AsyncResult(OnFacebookCallCompleted <T>, callback, state);

            SendRequestAsync(parameterList, useSession, result);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Makes a call to facebook server and returns the result in callback specified
 /// </summary>
 /// <typeparam name="T">Type of object to which result should be deserialized</typeparam>
 /// <param name="parameterList">parameters that needs to be passed to call</param>
 /// <param name="callback">Callback which will be called on response.</param>
 /// <param name="state">User defined object</param>
 public void SendRequestAsync <T>(Dictionary <string, string> parameterList, FacebookCallCompleted <T> callback, Object state)
 {
     SendRequestAsync(parameterList, true, callback, state);
 }