/// <summary> /// 计算若干个文件合并成的md5码 /// </summary> public string ComputeMd5WithDependencies(string[] assetPaths) { List <byte> list = new List <byte>(); foreach (var p in assetPaths) { byte[] buffer = ReadAssetBytes(p); if (buffer != null) { list.AddRange(buffer); } } // 依赖项 string[] dependencies = AssetDatabase.GetDependencies(assetPaths); byte[] bufferOfD; foreach (var d in dependencies) { bufferOfD = null; bufferOfD = ReadAssetBytes(d); if (bufferOfD != null) { list.AddRange(bufferOfD); } } return(TypeConvertUtility.ByteToMd5(list.ToArray())); }
public static List <T> ToList <T>(this IDataReader reader) { var result = new List <T>(); var itemType = typeof(T); var properties = itemType.GetPropertiesWithoutHidings(); while (reader.Read()) { T item; if (itemType.IsPrimitive || itemType == typeof(string)) { item = TypeConvertUtility.To <T>(reader.GetValue(0)); } else { item = Activator.CreateInstance <T>(); foreach (var prp in properties) { string fieldName = prp.Name; int fieldOrdinal = reader.GetFieldOrdinal(fieldName); if (fieldOrdinal >= 0) { if (prp.PropertyType == typeof(List <int>)) { List <int> propertyResult = null; var valueAsString = TypeConvertUtility.To <string>(reader.GetValue(fieldOrdinal)); if (!string.IsNullOrWhiteSpace(valueAsString) && valueAsString.Contains(",")) { propertyResult = propertyResult = (valueAsString ?? string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(p => int.Parse(p)) .ToList(); } prp.SetValue(item, propertyResult, null); } else { prp.SetValue(item, TypeConvertUtility.ToWithType(prp.PropertyType, reader.GetValue(fieldOrdinal)), null); } } } } result.Add(item); } return(result); }
/// <summary> /// 计算AB资源的Hash码 /// </summary> public string ComputeHash() { byte[] buffer = ReadAssetBundleBytes(); if (buffer != null) { m_currentHash = TypeConvertUtility.ByteToHash(buffer); } else { m_currentHash = ""; } return(m_currentHash); }
/// <summary> /// インスタンスを初期化します。 /// </summary> /// <param name="values">イベント データのコレクション。</param> internal WpdEventArgs(IPortableDeviceValues values) { uint count = 0; values.GetCount(ref count); if (count < 1) { this.Values = new List <WpdPropertyValue>(0); return; } this.Values = new List <WpdPropertyValue>(( int )count); var key = new _tagpropertykey(); var info = new tag_inner_PROPVARIANT(); for (uint i = 0; i < count; ++i) { values.GetAt(i, ref key, ref info); var value = new WpdPropertyValue(key, info, values); if (value.Key.Equals(WpdProperties.WPD_EVENT_PARAMETER_PNP_DEVICE_ID)) { this.DeviceId = value.ValueString; } else if (value.Key.Equals(WpdProperties.WPD_OBJECT_ID)) { this.ObjectId = value.ValueString; } else if (value.Key.Equals(WpdProperties.WPD_OBJECT_PARENT_ID)) { this.ParentObjectId = value.ValueString; } else if (value.Key.Equals(WpdProperties.WPD_EVENT_PARAMETER_EVENT_ID)) { if (value.ValueGuid != null) { this.Type = TypeConvertUtility.GuidToEventType(value.ValueGuid.Value); } } else { this.Values.Add(value); } } }
static void SaveLoadingListFile(List <BaseAssetManager> managerList, string path) { StringBuilder sb = new StringBuilder(); string itemPath, name, md5; int startIndex; byte[] bytes; for (int i = 0, j = 0; i < managerList.Count; i++) { for (j = 0; j < managerList[i].items.Length; j++) { var item = managerList[i].items[j]; if (item.flag == AssetFlag.NoChange) { itemPath = string.Format("{0}/{1}", BuildConfig.buildingAssetBundlesFolder, item.assetBundleName); } else { itemPath = string.Format("{0}/{1}", BuildConfig.tempbuildingAssetBundlesFolder, item.assetBundleName); } startIndex = BuildConfig.buildingAssetBundlesFolder.Length + 1; name = itemPath.Substring(startIndex); bytes = null; bytes = File.ReadAllBytes(itemPath); md5 = TypeConvertUtility.ByteToMd5(bytes); sb.AppendFormat("{0},{1},{2};", name, md5, bytes.Length); } } File.WriteAllText(path, sb.ToString()); }
/// <summary> /// 计算单个资源的md5码 /// </summary> public string ComputeMd5(string assetPath) { byte[] buffer = ReadAssetBytes(assetPath); return(buffer != null?TypeConvertUtility.ByteToMd5(buffer) : null); }