Exemplo n.º 1
0
        /// <summary>
        /// <para>FindAsync用レスポンス処理</para>
        /// <para>_mergeFromServerを呼びレスポンスデータ(JSONテキスト)からNCMBObject(リスト)を作成する</para>
        /// </summary>
        private ArrayList _convertFindResponse(Dictionary <string, object> response)
        {
            ArrayList     answer  = new ArrayList();
            List <object> results = (List <object>)response ["results"];

            if (results == null)
            {
                Debug.Log("null results in find response");
            }
            else
            {
                object objectClassName = null;
                string resultClassName = null;
                if (response.TryGetValue("className", out objectClassName))
                {
                    resultClassName = (string)objectClassName;
                }

                if (resultClassName == null)
                {
                    resultClassName = this._className;
                }

                for (int i = 0; i < results.Count; i++)
                {
                    NCMBObject obj = null;
                    if (resultClassName.Equals("user"))
                    {
                        obj = new NCMBUser();
                    }
                    else if (resultClassName.Equals("role"))
                    {
                        obj = new NCMBRole();
                    }
                    else if (resultClassName.Equals("installation"))
                    {
                        obj = new NCMBInstallation();

                        /*
                         * } else if (resultClassName.Equals ("push")) {
                         *      obj = new NCMBPush ();
                         */
                    }
                    else if (resultClassName.Equals("file"))
                    {
                        obj = new NCMBFile();
                    }
                    else
                    {
                        obj = new NCMBObject(resultClassName);
                    }
                    obj._mergeFromServer((Dictionary <string, object>)results [i], true);
                    answer.Add(obj);
                }
            }
            return(answer);
        }
Exemplo n.º 2
0
        /// <summary>
        /// <para>FindAsync用レスポンス処理</para>
        /// <para>_mergeFromServerを呼びレスポンスデータ(JSONテキスト)からNCMBObject(リスト)を作成する</para>
        /// </summary>
        private ArrayList _convertFindResponse(Dictionary <string, object> response)
        {
            ArrayList     answer  = new ArrayList();
            List <object> results = (List <object>)response ["results"];

            if (results == null)
            {
                Debug.Log("null results in find response");
            }
            else
            {
                object objectClassName = null;
                string resultClassName = null;
                if (response.TryGetValue("className", out objectClassName))
                {
                    resultClassName = (string)objectClassName;
                }

                if (resultClassName == null)
                {
                    resultClassName = this._className;
                }

                for (int i = 0; i < results.Count; i++)
                {
                    NCMBObject obj = null;
                    if (resultClassName.Equals("user"))
                    {
                        //resultClassNameは渡さなくて良い
                        //Android準拠[classNameはuserで固定][UserNameはresultのユーザー名]
                        obj = new NCMBUser();
                    }
                    else if (resultClassName.Equals("role"))
                    {
                        //Android準拠[classNameはroleで固定][Rolenameはresultのロール名]
                        //ここでresultClassName渡さなくてもobjectId,className諸々mergeFromeServerが行なう
                        obj = new NCMBRole();
                    }
                    else
                    {
                        obj = new NCMBObject(resultClassName);
                    }
                    obj._mergeFromServer((Dictionary <string, object>)results [i], true);
                    answer.Add(obj);
                }
            }
            return(answer);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 各型毎のURL作成
        /// </summary>
        private string _getSearchUrl(string className)
        {
            string url = "";

            if (className == null || className.Equals(""))
            {
                throw new ArgumentException("Not class name error. Please be sure to specify the class name.");
            }
            else if (className.Equals("push"))
            {
                // プッシュ検索API
                //url = new NCMBPush().getBaseUrl();
            }
            else if (className.Equals("installation"))
            {
                // 配信端末検索API
                //url = new NCMBInstallation().getBaseUrl();
            }
            else if (className.Equals("file"))
            {
                // ファイル検索API
                //url = new NCMBFile().getBaseUrl();
            }
            else if (className.Equals("user"))
            {
                // 会員検索API
                //url = new NCMBUser().getBaseUrl(NCMBUser.URL_TYPE_USER);
                url = new NCMBUser()._getBaseUrl();
            }
            else if (className.Equals("role"))
            {
                // ロール検索API
                url = new NCMBRole()._getBaseUrl();
                //url = new NCMBRole().getBaseUrl();
            }
            else
            {
                // オブジェクト検索API
                //※サブクラスを作るときはここでAndroidSDK,NCMBOBjectのcreateメソッドをつくる必要有り
                url = new NCMBObject(_className)._getBaseUrl();
            }
            return(url);
        }