Esempio n. 1
0
    /// <summary>
    /// Parses the string json into a value
    /// </summary>
    /// <param name="json">A JSON string.</param>
    /// <returns>An ArrayList, a Hashtable, a double, a string, null, true, or false</returns>
    public static object jsonDecode(string json)
    {
        // save the string for debug information
        ShareSDKMiniJSON.lastDecode = json;

        if (json != null)
        {
            char[] charArray = json.ToCharArray();
            int    index     = 0;
            bool   success   = true;
            object value     = ShareSDKMiniJSON.parseValue(charArray, ref index, ref success);

            if (success)
            {
                ShareSDKMiniJSON.lastErrorIndex = -1;
            }
            else
            {
                ShareSDKMiniJSON.lastErrorIndex = index;
            }

            return(value);
        }
        else
        {
            return(null);
        }
    }
Esempio n. 2
0
 void ShareResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
     
 {
     if (state == ResponseState.Success)
     {
         Debug.Log("---------------- share successfully - share result :");
         Debug.Log(ShareSDKMiniJSON.jsonEncode(result));
         EventDispatcher.Instance.TriggerEvent("ShareSDKReceiveMessageEvent", state);
     }
     else if (state == ResponseState.Fail)
     {
         #if UNITY_ANDROID
         Debug.Log("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]);
         #elif UNITY_IPHONE
         Debug.Log("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]);
         #endif
         EventDispatcher.Instance.TriggerEvent("ShareSDKReceiveMessageEvent", state);
     }
     else if (state == ResponseState.Cancel)
     {
         Debug.Log("cancel !");
         EventDispatcher.Instance.TriggerEvent("ShareSDKReceiveMessageEvent", state);
     }
         
 }
Esempio n. 3
0
    /// <summary>
    /// Converts a Hashtable / ArrayList / Dictionary(string,string) object into a JSON string
    /// </summary>
    /// <param name="json">A Hashtable / ArrayList</param>
    /// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns>
    public static string jsonEncode(object json)
    {
        var builder = new StringBuilder(BUILDER_CAPACITY);
        var success = ShareSDKMiniJSON.serializeValue(json, builder);

        return(success ? builder.ToString() : null);
    }
Esempio n. 4
0
 private void Prepare()
 {
     try
     {
         var      files           = System.IO.Directory.GetFiles(Application.dataPath, "MOB.keypds", System.IO.SearchOption.AllDirectories);
         string   filePath        = files [0];
         FileInfo projectFileInfo = new FileInfo(filePath);
         if (projectFileInfo.Exists)
         {
             StreamReader sReader  = projectFileInfo.OpenText();
             string       contents = sReader.ReadToEnd();
             sReader.Close();
             sReader.Dispose();
             Hashtable datastore = (Hashtable)ShareSDKMiniJSON.jsonDecode(contents);
             appKey    = (string)datastore["MobAppKey"];
             appSecret = (string)datastore["MobAppSecret"];
         }
         else
         {
             Debug.LogWarning("MOB.keypds no find");
         }
     }
     catch (Exception e)
     {
         if (appKey.Length == 0)
         {
             appKey    = "287b2742f28ca";
             appSecret = "a66d8dcdfc0a8b332f3a311ae6738014";
         }
         Debug.LogException(e);
     }
 }
Esempio n. 5
0
 private void Save()
 {
     try
     {
         var    files    = System.IO.Directory.GetFiles(Application.dataPath, "MOB.keypds", System.IO.SearchOption.AllDirectories);
         string filePath = files [0];
         if (File.Exists(filePath))
         {
             Hashtable datastore = new Hashtable();
             datastore["MobAppKey"]    = appKey;
             datastore["MobAppSecret"] = appSecret;
             var          json    = ShareSDKMiniJSON.jsonEncode(datastore);
             StreamWriter sWriter = new StreamWriter(filePath);
             sWriter.WriteLine(json);
             sWriter.Close();
             sWriter.Dispose();
         }
         else
         {
             Debug.LogWarning("MOB.keypds no find");
         }
     }
     catch (Exception e)
     {
         Debug.LogWarning("error");
         Debug.LogException(e);
     }
 }
Esempio n. 6
0
        public override Hashtable GetAuthInfo(PlatformType platform)
        {
            //need modify,
            string    credStr  = __iosShareSDKGetCredential((int)platform);
            Hashtable authInfo = (Hashtable)ShareSDKMiniJSON.jsonDecode(credStr);

            return(authInfo);
        }
Esempio n. 7
0
 public override Hashtable GetAuthInfo(PlatformType platform)
 {
     Debug.Log("AndroidImpl  ===>>>  GetAuthInfo");
     if (ssdk != null)
     {
         String result = ssdk.Call <String>("getAuthInfo", (int)platform);
         return((Hashtable)ShareSDKMiniJSON.jsonDecode(result));
     }
     return(new Hashtable());
 }
Esempio n. 8
0
        public override void SetPlatformConfig(Hashtable configs)
        {
            String json = ShareSDKMiniJSON.jsonEncode(configs);

            Debug.Log("AndroidImpl  ===>>>  SetPlatformConfig === " + json);
            if (ssdk != null)
            {
                ssdk.Call("setPlatformConfig", json);
            }
        }
Esempio n. 9
0
        public Hashtable GetShareParams()
        {
            if (customizeShareParams.Count > 0)
            {
                shareParams["customizeShareParams"] = customizeShareParams;
            }
            String jsonStr = ShareSDKMiniJSON.jsonEncode(shareParams);

            Debug.Log("ParseShareParams  ===>>> " + jsonStr);
            return(shareParams);
        }
Esempio n. 10
0
        public override void ShareContent(int reqID, PlatformType[] platforms, ShareContent content)
        {
            string platTypesStr = null;

            if (platforms != null)
            {
                List <int> platTypesArr = new List <int>();
                foreach (PlatformType type in platforms)
                {
                    platTypesArr.Add((int)type);
                }
                platTypesStr = ShareSDKMiniJSON.jsonEncode(platTypesArr.ToArray());
            }
            __iosShareSDKOneKeyShare(reqID, platTypesStr, content.GetShareParamsStr(), _callbackObjectName);
        }
Esempio n. 11
0
        public XCMod(string filename)
        {
            FileInfo projectFileInfo = new FileInfo(filename);

            if (!projectFileInfo.Exists)
            {
                Debug.LogWarning("File does not exist.");
            }

            name = System.IO.Path.GetFileNameWithoutExtension(filename);
            path = System.IO.Path.GetDirectoryName(filename);

            string contents = projectFileInfo.OpenText().ReadToEnd();

            _datastore = (Hashtable)ShareSDKMiniJSON.jsonDecode(contents);
        }
Esempio n. 12
0
        public override void ShowPlatformListWithContentName(int reqId, string contentName, Hashtable customFields, PlatformType[] platforms, int x, int y)
        {
            String customFieldsStr = ShareSDKMiniJSON.jsonEncode(customFields);
            string platTypesStr    = null;

            if (platforms != null)
            {
                List <int> platTypesArr = new List <int>();
                foreach (PlatformType type in platforms)
                {
                    platTypesArr.Add((int)type);
                }
                platTypesStr = ShareSDKMiniJSON.jsonEncode(platTypesArr.ToArray());
            }

            __iosShareSDKShowShareMenuWithContentName(reqId, contentName, customFieldsStr, platTypesStr, x, y, _callbackObjectName);
        }
Esempio n. 13
0
        /// <summary>
        /// callback the specified data.
        /// </summary>
        /// <param name='data'>
        /// Data.
        /// </param>
        private void _Callback(string data)
        {
            if (data == null)
            {
                return;
            }

            Hashtable res = (Hashtable)ShareSDKMiniJSON.jsonDecode(data);

            if (res == null || res.Count <= 0)
            {
                return;
            }

            int          status   = Convert.ToInt32(res["status"]);
            int          reqID    = Convert.ToInt32(res["reqID"]);
            PlatformType platform = (PlatformType)Convert.ToInt32(res["platform"]);
            int          action   = Convert.ToInt32(res["action"]);

            // Success = 1, Fail = 2, Cancel = 3
            switch (status)
            {
            case 1:
            {
                Console.WriteLine(data);
                Hashtable resp = (Hashtable)res["res"];
                OnComplete(reqID, platform, action, resp);
                break;
            }

            case 2:
            {
                Console.WriteLine(data);
                Hashtable throwable = (Hashtable)res["res"];
                OnError(reqID, platform, action, throwable);
                break;
            }

            case 3:
            {
                OnCancel(reqID, platform, action);
                break;
            }
            }
        }
Esempio n. 14
0
        //shareSDK
        private void checkPlatforms(DevInfoSet devInfo)
        {
            Type type = devInfo.GetType();

            FieldInfo[] devInfoFields   = type.GetFields();
            Hashtable   enablePlatforms = new Hashtable();

            foreach (FieldInfo devInfoField in devInfoFields)
            {
                DevInfo info = (DevInfo)devInfoField.GetValue(devInfo);
                if (info.Enable)
                {
                    int    platformId = (int)info.GetType().GetField("type").GetValue(info);
                    string appkey     = GetAPPKey(info, platformId);
                    enablePlatforms.Add(platformId, appkey);
                }
            }
            var      files           = System.IO.Directory.GetFiles(Application.dataPath, "ShareSDK.mobpds", System.IO.SearchOption.AllDirectories);
            string   filePath        = files [0];
            FileInfo projectFileInfo = new FileInfo(filePath);

            if (projectFileInfo.Exists)
            {
                StreamReader sReader  = projectFileInfo.OpenText();
                string       contents = sReader.ReadToEnd();
                sReader.Close();
                sReader.Dispose();
                Hashtable datastore = (Hashtable)ShareSDKMiniJSON.jsonDecode(contents);
                if (datastore.ContainsKey("ShareSDKPlatforms"))
                {
                    datastore["ShareSDKPlatforms"] = enablePlatforms;
                }
                else
                {
                    datastore.Add("ShareSDKPlatforms", enablePlatforms);
                }
                var          json    = ShareSDKMiniJSON.jsonEncode(datastore);
                StreamWriter sWriter = new StreamWriter(filePath);
                sWriter.WriteLine(json);
                sWriter.Close();
                sWriter.Dispose();
            }
        }
Esempio n. 15
0
        //读取配置debug.logdebug.log
        private void ReadMobpds(string filePath, string appkey, string savefilePath)
        {
            FileInfo fileInfo = new FileInfo(filePath);

            if (fileInfo.Exists)
            {
                StreamReader sReader  = fileInfo.OpenText();
                string       contents = sReader.ReadToEnd();
                sReader.Close();
                sReader.Dispose();
                Hashtable datastore = (Hashtable)ShareSDKMiniJSON.jsonDecode(contents);
                //savefilePath
                int index = filePath.LastIndexOf("/");
                if (savefilePath == null)
                {
                    savefilePath = filePath;
                    savefilePath = savefilePath.Substring(0, index);
                }
//				Debug.LogWarning (savefilePath);
                //permissionsreplaceAppKeydebug.logdebug.log
                AddPrmissions(datastore);
                //LSApplicationQueriesSchemes
                AddLSApplicationQueriesSchemes(datastore, appkey);
                //folders
                AddFolders(datastore, savefilePath);
                //buildSettings
                AddBuildSettings(datastore);
                //系统库添加
                AddSysFrameworks(datastore);
                //添加非系统 Framework 配置需要设置指定参数
                AddFrameworks(datastore, savefilePath);
                //添加 URLSchemes
                AddURLSchemes(datastore, appkey);
                //添加 InfoPlistSet
                AddInfoPlistSet(datastore, appkey);
                //子平台
                AddPlatformConf(datastore, savefilePath);
                //添加 fileFlags 一些需要特殊设置编译标签的文件 如ARC下MRC
                AddFileFlags(datastore);
            }
        }
Esempio n. 16
0
 //for shareSDK
 private void SetPlatformConfList()
 {
     string[] files = Directory.GetFiles(Application.dataPath, "All.pltpds", SearchOption.AllDirectories);
     if (files.Length > 0)
     {
         string   filePath = files[0];
         FileInfo fileInfo = new FileInfo(filePath);
         if (fileInfo.Exists)
         {
             StreamReader sReader  = fileInfo.OpenText();
             string       contents = sReader.ReadToEnd();
             sReader.Close();
             sReader.Dispose();
             platformConfList = (Hashtable)ShareSDKMiniJSON.jsonDecode(contents);
         }
         else
         {
             platformConfList = new Hashtable();
         }
     }
 }
Esempio n. 17
0
    //在info.plist中添加 MOBAppkey MOBAppSecret
    private static void AddAPPKey(PlistElementDict plistElements)
    {
        var      files           = System.IO.Directory.GetFiles(Application.dataPath, "MOB.keypds", System.IO.SearchOption.AllDirectories);
        string   filePath        = files [0];
        FileInfo projectFileInfo = new FileInfo(filePath);

        if (projectFileInfo.Exists)
        {
            StreamReader sReader  = projectFileInfo.OpenText();
            string       contents = sReader.ReadToEnd();
            sReader.Close();
            sReader.Dispose();
            Hashtable datastore = (Hashtable)ShareSDKMiniJSON.jsonDecode(contents);
            string    appKey    = (string)datastore["MobAppKey"];
            string    appSecret = (string)datastore["MobAppSecret"];
            plistElements.SetString("MOBAppkey", appKey);
            plistElements.SetString("MOBAppSecret", appSecret);
        }
        else
        {
            Debug.LogWarning("MOB.keypds no find");
        }
    }
Esempio n. 18
0
        public override void SetPlatformConfig(Hashtable configs)
        {
            String json = ShareSDKMiniJSON.jsonEncode(configs);

            __iosShareSDKRegisterAppAndSetPltformsConfig(_appKey, json);
        }
Esempio n. 19
0
 public static string toJson(this Hashtable obj)
 {
     return(ShareSDKMiniJSON.jsonEncode(obj));
 }
Esempio n. 20
0
        public override void ShowShareContentEditorWithContentName(int reqId, PlatformType platform, string contentName, Hashtable customFields)
        {
            String customFieldsStr = ShareSDKMiniJSON.jsonEncode(customFields);

            __iosShareSDKShowShareViewWithContentName(reqId, (int)platform, contentName, customFieldsStr, _callbackObjectName);
        }
Esempio n. 21
0
 public static string toJson(this Dictionary <string, string> obj)
 {
     return(ShareSDKMiniJSON.jsonEncode(obj));
 }
Esempio n. 22
0
 public static ArrayList arrayListFromJson(this string json)
 {
     return(ShareSDKMiniJSON.jsonDecode(json) as ArrayList);
 }
Esempio n. 23
0
 public static Hashtable hashtableFromJson(this string json)
 {
     return(ShareSDKMiniJSON.jsonDecode(json) as Hashtable);
 }