Пример #1
0
 // 获取需要更新的资源路径
 private void GetUpdateResPaths(ResListInfo onlineResListInfo, ResListInfo curResListInfo, ref List <SingleResInfo> updateList)
 {
     if (curResListInfo != null)
     {
         if (!onlineResListInfo.Ver.Equals(curResListInfo.Ver))
         {
             // TODO  需要测试一下Linq性能
             updateList = onlineResListInfo.Info.Where(onlineData => !curResListInfo.Info.Where(curData => onlineData.Md5 == curData.Md5 &&
                                                                                                onlineData.Path == curData.Path && onlineData.Status == curData.Status && onlineData.Size == curData.Size).Any()).ToList();
         }
         else
         {
             foreach (var item in onlineResListInfo.Info) // TODO 检测文件是否需要更新的计算方式 感觉不是很好(后续有更好的方案再改)
             {
                 stringBuilder.Clear();
                 stringBuilder.Append(PathUtility.Instance.GetPersistentDataPath());
                 stringBuilder.Append("/");
                 stringBuilder.Append(item.Path);
                 string localFileMd5 = ToolUtility.GetFileMD5Str(stringBuilder.ToString());
                 if (localFileMd5 != item.Md5)
                 {
                     updateList.Add(item);
                 }
             }
         }
     }
     else
     {
         updateList.AddRange(onlineResListInfo.Info);
     }
 }