Beispiel #1
0
        public static object Deserialize(string txt, object context = null)
        {
            JsonSerializer.deserializeCache = new Dictionary <long, object>();
            JsonSerializer.typeCache        = new Dictionary <long, Type>();
            object obj    = MiniJson.JsonDecode(txt);
            object result = null;

            if (obj != null)
            {
                JsonSerializer.ConstructClassTable((Hashtable)((Hashtable)obj)[STR_CLS_TABLE]);
                result = JsonSerializer.Deserialize(obj, obj.GetType(), context);
            }

            JsonSerializer.deserializeCache.Clear();
            JsonSerializer.deserializeCache = null;
            JsonSerializer.typeCache.Clear();
            JsonSerializer.typeCache = null;

            return(result);
        }
Beispiel #2
0
        public void Load(string contentJson)
        {
            dict.Clear();
            Hashtable jsonDict = MiniJson.JsonDecode(contentJson) as Hashtable;

            refId = jsonDict.Get <long>("ref_id");
            ArrayList assetPathRefList = jsonDict.Get <ArrayList>("assetPathRef_list");

            for (var i = 0; i < assetPathRefList.Count; i++)
            {
                var    assetPathRefDict = (Hashtable)assetPathRefList[i];
                long   refId            = assetPathRefDict.Get <long>("ref_id");
                string assetPath        = assetPathRefDict.Get <string>("assetPath");
                string guid             = assetPathRefDict.Get <string>("guid");
                if (refId > this.refId)
                {
                    this.refId = refId;
                }
                dict[guid] = new AssetPathRef(refId, assetPath, guid);
            }
        }
Beispiel #3
0
        private void SaveUser()
        {
            User      user        = Client.instance.user;
            Hashtable dictUser    = new Hashtable();
            Hashtable dictUserTmp = new Hashtable();

            user.DoSave(dictUser, dictUserTmp);
            string userId = user.GetId();


            Hashtable saveData = new Hashtable();

            saveData["dict_user"]     = dictUser;
            saveData["dict_user_tmp"] = dictUserTmp;
            saveData["user_id"]       = userId;

            var content      = MiniJson.JsonEncode(saveData);
            var contentBytes = Encoding.UTF8.GetBytes(content);

            //contentBytes = CompressUtil.GZipCompress(contentBytes);//ѹËõ
            StdioUtil.WriteFile(filePath, contentBytes);
        }
Beispiel #4
0
        public void SingleInit()
        {
            var fileInfo = new FileInfo(filePath);

            if (!fileInfo.Exists)
            {
                var org_data = new Hashtable()
                {
                    { "user_id", "user1" },
                    { "dict_user_tmp", new Hashtable() },
                    { "dict_user", new Hashtable() }
                };
                data = org_data;
                return;
            }

            var conentBytes = StdioUtil.ReadFile(filePath);
            //conentBytes = CompressUtil.GZipDecompress(conentBytes);--½âѹËõ
            var content = Encoding.UTF8.GetString(conentBytes);

            data = MiniJson.JsonDecode(content) as Hashtable;
        }
Beispiel #5
0
        public void Save()
        {
            Refresh();
            Hashtable jsonDict = new Hashtable();

            jsonDict["ref_id"] = refId;
            ArrayList assetPathRefList = new ArrayList();

            foreach (var keyValue in dict)
            {
                var       assetPathRef     = keyValue.Value;
                Hashtable assetPathRefDict = new Hashtable();
                assetPathRefDict["ref_id"]    = assetPathRef.refId;
                assetPathRefDict["assetPath"] = assetPathRef.assetPath;
                assetPathRefDict["guid"]      = assetPathRef.guid;
                assetPathRefList.Add(assetPathRefDict);
            }

            jsonDict["assetPathRef_list"] = assetPathRefList;
            string contentJson = MiniJson.JsonEncode(jsonDict);

            StdioUtil.WriteTextFile(AssetPathRefConst.SaveFilePath.WithRootPath(FilePathConst.ProjectPath), contentJson);
        }