public DownloadItemModel JsonToModelString(TinyJson.Node node)
 {
     DownloadUrl           = node["DownloadUrl"].ToString();
     FileSaveName          = node["FileSaveName"].ToString();
     FragmentsFileSaveName = node["FragmentsFileSaveName"].ToString();
     DownloadSize          = long.Parse(node["DownloadSize"].ToString());
     DownloadProgressValue = float.Parse(node["DownloadProgressValue"].ToString());
     DownloadedSize        = long.Parse(node["DownloadedSize"].ToString());
     IsDownloadFinsh       = bool.Parse(node["IsDownloadFinsh"].ToString());
     DownloadSpeedValue    = node["DownloadSpeedValue"].ToString();
     Tag  = node["Tag"].ToString();
     Data = node["Data"].ToString();
     ID   = node["ID"].ToString();
     return(this);
 }
        /// <summary>
        /// 读取本地缓存文件
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="moduleName"></param>
        /// <param name="childModuleNameId"></param>
        /// <returns></returns>
        public T ReadDictionary <T>(string moduleName, string childModuleNameId) where T : IBaseItemModel <T>, new()
        {
            T tempModel = default(T);

            TinyJson.Node resultNode = TinyJson.Parser.Instance.Load(File.ReadAllText(GetCachePath(moduleName, childModuleNameId)));
            if (resultNode != null)
            {
                tempModel = new T();
                tempModel.JsonToModelString(resultNode);
            }
            else
            {
                Debug.LogError(string.Format("ReadDictionary ==>  moduleName : {0} childModuleNameId : {1} Decode Error ", moduleName, childModuleNameId));
            }
            return(tempModel);
        }
        /// <summary>
        /// 读取本地缓存文件
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="moduleName"></param>
        /// <param name="childModuleNameId"></param>
        /// <returns></returns>
        public List <T> ReadList <T>(string moduleName, string childModuleNameId) where T : IBaseItemsModel <T>, new()
        {
            List <T> followItemModel = new List <T>();

            TinyJson.Node resultNode = TinyJson.Parser.Instance.Load(File.ReadAllText(GetCachePath(moduleName, childModuleNameId)));
            if (resultNode != null)
            {
                if (resultNode.IsArray())
                {
                    List <TinyJson.Node> lists = (List <TinyJson.Node>)resultNode;
                    foreach (TinyJson.Node node in lists)
                    {
                        T tempModel = new T();
                        followItemModel.Add(tempModel.JsonToModelString(node));
                    }
                }
            }
            else
            {
                Debug.LogError(string.Format(" ReadList ==> moduleName : {0} childModuleNameId : {1} Decode Error ", moduleName, childModuleNameId));
            }
            return(followItemModel);
        }
예제 #4
0
 public abstract T JsonToModelString(TinyJson.Node jsonNode);