Example #1
0
 //将对象序列化到文件
 public static void SerializeToFilePath <T>(T t, string file_path) where T : Google.Protobuf.IMessage
 {
     using (File.Create(file_path))
     {
         StdioUtil.WriteFile(new FileInfo(file_path), Serialize(t));
     }
 }
Example #2
0
        public virtual void Save()
        {
            var content      = JsonSerializer.Serialize(this);
            var contentBytes = Encoding.UTF8.GetBytes(content);

            //contentBytes = CompressUtil.GZipCompress(contentBytes);//压缩
            StdioUtil.WriteFile(SerializeDataConst.SaveFilePathCS, contentBytes);
        }
Example #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);
        }
Example #4
0
        private void OnResourceWebRequesterDone(ResourceWebRequester resourceWebRequester)
        {
            //    LogCat.LogError("kkkkkkkkkkkkkkk:"+resourceWebRequester.url);
            if (!downloadingRequestList.Contains(resourceWebRequester))
            {
                return;
            }

            if (!resourceWebRequester.error.IsNullOrWhiteSpace())
            {
                LogCat.LogError("Error when downloading file : " + resourceWebRequester.cache.Get <string>("file_path") +
                                "\n from url : " +
                                resourceWebRequester.url + "\n err : " + resourceWebRequester.error);
                needDownloadList.Add(resourceWebRequester.cache.Get <string>("file_path"));
            }
            else
            {
                downloadingRequestList.Remove(resourceWebRequester);
                needDownloadDict[resourceWebRequester.cache.Get <string>("file_path")]["is_finished"]     = true;
                needDownloadDict[resourceWebRequester.cache.Get <string>("file_path")]["downloded_bytes"] =
                    needDownloadDict[resourceWebRequester.cache.Get <string>("file_path")]["total_bytes"];
                var filePath = resourceWebRequester.cache.Get <string>("file_path")
                               .WithRootPath(FilePathConst.PersistentAssetBundleRoot);
                StdioUtil.WriteFile(filePath, resourceWebRequester.bytes);
            }

            resourceWebRequester.Destroy();
            PoolCatManagerUtil.Despawn(resourceWebRequester);

            //    LogCat.LogError("ffffffffffffaaaaaaa:"+downloadingRequest.Count);
            //    LogCat.LogError("ffffffffffffbbbbbbb:" + needDownloadList.Count);
            if (downloadingRequestList.Count == 0 && needDownloadList.Count == 0)
            {
                isUpdatingRes = false;
            }
        }
Example #5
0
        public void SaveToDisk()
        {
            var path = assetBundleName.WithRootPath(FilePathConst.PersistentAssetBundleRoot);

            StdioUtil.WriteFile(path, manifestBytes);
        }