private void GetUserInfoPreCompleted(IList<user> users, object state, FacebookException e)
 {
     user currentUser = users[0];
     var hashes = new List<string>();
     hashes.Add(currentUser.email_hashes.email_hashes_elt[0]);
     _api.Connect.UnregisterUsersAsync(hashes, UnregisterUsersTestCompleted, null);
 }
 private void MultiqueryCompleted(IList<fql_result> results, object state, FacebookException e)
 {
     Assert.IsNotNull(results);
     Assert.IsTrue(results.Count == 2);
     Assert.IsTrue(results[0].name == "firstQuery");
     EnqueueTestComplete();
 }
 private void GetInfoCompleted(IList<page> actual, object state, FacebookException e)
 {
     Assert.IsNotNull(actual);
     Assert.IsTrue(actual.Count > 0);
     Assert.IsNotNull(actual[0].name);
     EnqueueTestComplete();
 }
        void OnGetLoggedInUser(long userId, Object state, FacebookException e)
        {
            if (e == null)
            {
                this.UserId = userId;
            }

            this.OnLoggedIn(e);
        }
 private void OnGetForRegisterGetTestCompleted(template_bundle expected, object state, FacebookException e)
 {
     var actual = (long)state;
     Assert.AreEqual(expected.template_bundle_id, actual);
     EnqueueTestComplete();
 }
        private void OnGetForDeactivateCompleted(template_bundle expected, object state, FacebookException e)
        {
            var actual = (long)state;
            Assert.AreEqual(expected.template_bundle_id, actual);

            _apiWeb.Feed.DeactivateTemplateBundleByIDAsync(actual.ToString(), OnDeactivateCompleted, null);
        }
 private void GetMembersCompleted(group_members actual, object state, FacebookException e)
 {
     Assert.IsTrue(actual.members.uid.Count > 0);
     EnqueueTestComplete();
 }
 private void GrantApiAccessCompleted(bool result, object state, FacebookException e)
 {
     Assert.IsTrue(result);
     EnqueueTestComplete();
 }
 private void OnRegisterForRegisterGetTestCompleted(long actual, object state, FacebookException e)
 {
     _api.Feed.GetRegisteredTemplateBundleByIDAsync(actual, OnGetForRegisterGetTestCompleted, actual);
 }
 private void OnRegisterForGetBundlesCompleted(long bundleId, object state, FacebookException e)
 {
     _apiWeb.Feed.GetRegisteredTemplateBundlesAsync(OnGetRegisteredTemplateBundlesCompleted, null);
 }
 private void GetUnconnectedFriendsTestCompleted(int friendCount, object state, FacebookException e)
 {
     Assert.IsNotNull(friendCount);
     EnqueueTestComplete();
 }
 private void GetCompleted(IList<comment> actual, object state, FacebookException e)
 {
     Assert.IsNotNull(actual);
     EnqueueTestComplete();
 }
 private void AddForRemoveCompleted(int commentId, object state, FacebookException e)
 {
     _api.Comments.RemoveAsync("xid_test", commentId, RemoveCompleted, null);
 }
 private void Add4Completed(int commentId, object state, FacebookException e)
 {
     Assert.IsTrue(commentId > 0);
     EnqueueTestComplete();
 }
 private void RemoveCompleted(bool result, object state, FacebookException e)
 {
     Assert.IsTrue(result);
     EnqueueTestComplete();
 }
        private static void OnGetAppPropertiesCompleted(string result, Object state, FacebookException e)
        {
            Object[] stateArray = state != null ? (Object[]) state : null;
            GetAppPropertiesCallback callback = stateArray != null && stateArray.Length > 0 ? (GetAppPropertiesCallback)stateArray[0] : null;
            var originalState = stateArray != null && stateArray.Length > 1 ? stateArray[1] : null;

            if (e == null)
            {
                if(callback != null)
                    callback(JSONHelper.ConvertFromJSONAssoicativeArray(result), originalState, e);
            }
            else
            {
                if(callback != null)
                    callback(null, originalState, e);
            }
        }
 private void OnGetRegisteredTemplateBundlesCompleted(IList<template_bundle> actual, object state, FacebookException e)
 {
     Assert.IsTrue(actual.Count > 0);
     EnqueueTestComplete();
 }
 private void GetUserInfoPostCompleted(IList<user> users, object state, FacebookException e)
 {
     user currentUser = users[0];
     Assert.IsNull(currentUser.email_hashes);
     EnqueueTestComplete();
 }
 private void OnPublishUserActionCompleted(bool actual, object state, FacebookException ex)
 {
     Assert.IsTrue(actual);
     EnqueueTestComplete();
 }
 private void GetUploadLimitsCompleted(video_limits actual, object state, FacebookException e)
 {
     Assert.IsNotNull(actual);
     EnqueueTestComplete();
 }
        private void OnRegisterForPublishUserActionCompleted(long templateBundleId, object state, FacebookException e)
        {
            List<long> friendTargets = new List<long> { Constants.FBSamples_friend1, Constants.FBSamples_friend2 };
            Dictionary<string, string> body_data = new Dictionary<string, string> { { "host", "Run" } };

            _api.Feed.PublishUserActionAsync(templateBundleId, body_data, friendTargets, null, Feed.PublishedStorySize.Short, OnPublishUserActionCompleted, null);
        }
 /// <summary>
 /// Creates new DataCollectionErrorEventArgs object
 /// </summary>
 /// <param name="exception"></param>
 internal DataRetrievalCompletedEventArgs(FacebookException exception)
 {
     this.Exception = exception;
 }
        private void ContinueDeactivatingBundles(IList<template_bundle> bundles, object state, FacebookException e)
        {
            var callback = (FeedTestCallback)state;

            if (bundles.Count == 0)
            {
                callback();
                return;
            }

            var nextBundle = bundles[0];
            bundles.Remove(nextBundle);
            Facebook.Rest.Feed.DeactivateTemplateBundleByIDCallback deactivateCallback = (result, state2, e2) => ContinueDeactivatingBundles(bundles, state, e);
            _apiWeb.Feed.DeactivateTemplateBundleByIDAsync(nextBundle.template_bundle_id.ToString(), deactivateCallback, null);
        }
 private void CheckGrantedApiAccessCompleted(IList<string> actual, object state, FacebookException e)
 {
     Assert.IsNotNull(actual);
     EnqueueTestComplete();
 }
        void PermissionCheckCallBack(permissions_response permission, Object state, FacebookException ex)
        {
            List<Enums.ExtendedPermissions> permissionsToApprove = new List<Enums.ExtendedPermissions>();

            if (ex == null)
            {
                foreach (Enums.ExtendedPermissions p in this._permissions)
                {
                    FieldInfo f = permission.permissions.GetType().GetField(p.ToString());
                    if (f != null)
                    {
                        bool hasPermission = (bool)f.GetValue(permission.permissions);
                        if (!hasPermission)
                        {
                            permissionsToApprove.Add(p);
                        }
                    }
                }

                if (permissionsToApprove.Count != 0)
                {
                    string permString = PermissionsToString(permissionsToApprove.ToArray());
                    InvokeScriptCall("facebook_prompt_permission", permString);
                }
                else
                {
                    OnPermissionCheckCompleted(PermissionsToString(this._permissions), null);
                }
            }
            else
            {
                OnPermissionCheckCompleted(null, ex);
            }
        }
 private void RegisterUsersTestCompleted(IList<string> result, object state, FacebookException e)
 {
     Assert.IsTrue(result.Count == 2);
     EnqueueTestComplete();
 }
 private void GetCompleted(IList<group> actual, object state, FacebookException e)
 {
     Assert.IsTrue(actual.Count > 0);
     EnqueueTestComplete();
 }
 private void UnregisterUsersTestCompleted(IList<string> result, object state, FacebookException e)
 {
     Assert.IsTrue(result.Count == 1);
        _api.Users.GetInfoAsync(Constants.FBSamples_UserId, GetUserInfoPostCompleted, null);
 }
        /// <summary>
        /// Mark this operation as completed, set the waitHandle and call the callback delegate
        /// </summary>
        /// <param name="result"></param>
        /// <param name="e">the result of this operation if it was an exception (can be null)</param>
        public virtual void SetComplete(string result, FacebookException e)
        {
            int wasCompleted = Interlocked.Exchange(ref isComplete, 1);
            if (wasCompleted == 1)
            {
                // can't call this if the operation is already set as completed
                throw new InvalidOperationException();
            }

            Result = result;
            Exception = e;

            // set this only if created. No use setting on one that has no threads waiting
            if (waitHandler != null)
            {
                waitHandler.Set();
            }

            // invoke user's callback is provided
            if (callback != null)
            {
                callback(this);
            }
        }
 private void OnDeactivateCompleted(bool deactivated, object state, FacebookException e)
 {
     Assert.IsTrue(deactivated);
     EnqueueTestComplete();
 }