/// <summary> /// 在list中找sublist的开始位置 /// </summary> /// <returns>-1表示没找到</returns> public static int IndexOfSub <T>(this List <T> self, List <T> subList) { var resultFromIndex = -1; //sublist在list中的开始位置 for (var i = 0; i < self.Count; i++) { object o = self[i]; if (!ObjectUtil.Equals(o, subList[0])) { continue; } var isEquals = true; for (var j = 1; j < subList.Count; j++) { var o1 = subList[j]; var o2 = i + j > self.Count - 1 ? default : self[i + j]; if (ObjectUtil.Equals(o1, o2)) { continue; } isEquals = false; break; } if (!isEquals) { continue; } resultFromIndex = i; break; } return(resultFromIndex); }
public AutoSetValue <T> IfChanged(Action <T, T> action) { if (!ObjectUtil.Equals(preValue, postValue)) { action(preValue, postValue); } return(this); }
public static string ToStringOrDefault(this Vector2 self, string to_default_string = null, Vector2 default_value = default(Vector2)) { if (ObjectUtil.Equals(self, default_value)) { return(to_default_string); } return(self.ToString()); }
public static Array Remove(Array sourceArray, object o) { var elementType = sourceArray != null?sourceArray.GetType().GetElementType() : o.GetType(); var sourceArrayLength = sourceArray?.Length ?? 0; if (sourceArrayLength == 0) { return(sourceArray); } int toRemoveIndex = -1; for (int i = 0; i < sourceArrayLength; i++) { if (!ObjectUtil.Equals(sourceArray.GetValue(i), o)) { continue; } toRemoveIndex = i; break; } if (toRemoveIndex == -1) { return(sourceArray); } var array = Array.CreateInstance(elementType, sourceArrayLength - 1); if (toRemoveIndex != 0) { Array.Copy(sourceArray, 0, array, 0, toRemoveIndex); } if (toRemoveIndex != sourceArrayLength - 1) { Array.Copy(sourceArray, toRemoveIndex + 1, array, toRemoveIndex, sourceArrayLength - toRemoveIndex - 1); } return(array); }
public static void RemoveByValue <K, V>(this IDictionary <K, V> self, V value, bool isAll = false) { bool isHasRemoveKey = false; if (isAll == false) { K toRemoveKey = default; foreach (var key in self.Keys) { if (!ObjectUtil.Equals(self[key], value)) { continue; } isHasRemoveKey = true; toRemoveKey = key; break; } if (isHasRemoveKey) { self.Remove(toRemoveKey); } return; } List <K> toRemoveKeyList = new List <K>(self.Count); foreach (var key in self.Keys) { if (ObjectUtil.Equals(self[key], value)) { toRemoveKeyList.Add(key); } } foreach (var toRemoveKey in toRemoveKeyList) { self.Remove(toRemoveKey); } }
public override bool Equals(object obj) { var other = (ObjectInfos)obj; if (other == null) { return(false); } var otherList = other.GetList(); if (_list.Count != otherList.Count) { return(false); } for (var i = _list.Count - 1; i >= 0; i--) { if (!ObjectUtil.Equals(_list[i], otherList[i])) { return(false); } } return(true); }
public override bool Equals(object obj) { Args other = (Args)obj; if (other == null) { return(false); } if (this.args == null && other.args == null) { return(true); } if (this.args == null && other.args != null) { return(false); } if (this.args != null && other.args == null) { return(false); } if (this.args.Length == other.args.Length) { for (int i = 0; i < this.args.Length; i++) { if (!ObjectUtil.Equals(args[i], other.args[i])) { return(false); } } return(true); } return(false); }
public static string ToStringOrDefault(this Matrix4x4 self, string toDefaultString = null, Matrix4x4 defaultValue = default) { return(ObjectUtil.Equals(self, defaultValue) ? toDefaultString : self.ToString()); }
public static string ToHtmlStringRGBAOrDefault(this Color self, string toDefaultValue = null, Color defaultColor = default) { return(ObjectUtil.Equals(self, defaultColor) ? toDefaultValue : self.ToHtmlStringRGBA()); }
public static string ToStringOrDefault(this Vector2Int self, string toDefaultString = null, Vector2Int defaultValue = default) { return(ObjectUtil.Equals(self, defaultValue) ? toDefaultString : self.ToString()); }
public IEnumerator CheckUpdate() { if (Application.isEditor && EditorModeConst.IsEditorMode) { isUpdateFinish = true; yield break; } downloadingRequestList.Clear(); clientBuildInfo = new BuildInfo(FilePathConst.PersistentAssetBundleRoot); serverBuildInfo = new BuildInfo(URLSetting.Server_Resource_URL); // LogCat.LogWarning("fffffffffffffff1:"+ FilePathConst.GetPersistentAssetBundleRoot()); // LogCat.LogWarning("fffffffffffffff2:"+ URLSetting.SERVER_RESOURCE_URL); //Update AssetPathRefContentJson yield return(clientBuildInfo.LoadAssetPathRefContentJson()); yield return(serverBuildInfo.LoadAssetPathRefContentJson()); if (!ObjectUtil.Equals(clientBuildInfo.assetPathRefContentJson, serverBuildInfo.assetPathRefContentJson)) { StdioUtil.WriteTextFile(clientBuildInfo.WithRootPathOfUrlRoot(AssetPathRefConst.SaveFileName).Trim(), serverBuildInfo.assetPathRefContentJson); } AssetPathRefManager.instance.Load(serverBuildInfo.assetPathRefContentJson); //Update ResVersion yield return(clientBuildInfo.LoadResVersion()); yield return(serverBuildInfo.LoadResVersion()); if (!BuildUtil.CheckResVersionIsNew(clientBuildInfo.resVersion, serverBuildInfo.resVersion)) { UpdateResFinish(); yield break; } //Update Mainfest yield return(clientBuildInfo.LoadManifest()); yield return(serverBuildInfo.LoadManifest()); yield return(serverBuildInfo.LoadAssetBundleMap()); needDownloadList.Clear(); needDownloadList = BuildUtil.GetManifestDiffAssetBundleList(clientBuildInfo.manifest, serverBuildInfo.manifest); if (!needDownloadList.IsNullOrEmpty()) { for (var i = 0; i < needDownloadList.Count; i++) { var assetBundleName = needDownloadList[i]; needDownloadDict[assetBundleName] = new Hashtable(); needDownloadDict[assetBundleName]["is_finished"] = false; needDownloadDict[assetBundleName]["total_bytes"] = serverBuildInfo.assetBundleMap.dict[assetBundleName]; needDownloadDict[assetBundleName]["downloded_bytes"] = (long)0; totalNeedDownloadBytes += serverBuildInfo.assetBundleMap.dict[assetBundleName]; } yield return(serverBuildInfo.LoadAssetPathMap()); yield return(UpdateRes()); serverBuildInfo.manifest.SaveToDisk(); serverBuildInfo.assetPathMap.SaveToDisk(); serverBuildInfo.assetBundleMap.SaveToDisk(); } UpdateResFinish(); }
public static Color ToColorOrDefault(this string self, string toDefaultString = null, Color defaultValue = default) { return(ObjectUtil.Equals(self, toDefaultString) ? defaultValue : self.ToColor()); }
public static Matrix4x4 ToMatrix4x4OrDefault(this string self, string toDefaultString = null, Matrix4x4 defaultValue = default(Matrix4x4)) { return(ObjectUtil.Equals(self, toDefaultString) ? defaultValue : self.ToMatrix4x4()); }
public static Vector3 ToVector4OrDefault(this string self, string toDefaultString = null, Vector4 defaultValue = default) { return(ObjectUtil.Equals(self, toDefaultString) ? defaultValue : self.ToVector4()); }