/// <summary> /// 同步加载 /// </summary> /// <param name="fullPath"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public T Load <T>(string path) where T : UnityEngine.Object { if (!this.loder.Manifest.IsHashName) { path = ZString.Format(RUNTIME, path); } //1.依赖路径 var item = loder.Manifest.GetManifest(path); if (item != null) { //加载依赖 foreach (var dependAsset in item.Depend) { LoadAssetBundle(dependAsset); } //加载主资源 LoadAssetBundle(item.Path); // return(LoadFormAssetBundle <T>(path, item)); } return(null); }
/// <summary> /// load ALL TestAPI /// 这个有一定局限性,这里是返回某个Ab中的所有资源 /// 简单处理一些简单资源情况:目前只解决图集 /// 仅作为某些项目补坑用 /// </summary> /// <param name="path"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public T[] LoadAll_TestAPI_2020_5_23 <T>(string path) where T : Object { if (!this.loder.Manifest.IsHashName) { path = ZString.Format(RUNTIME, path); } var item = loder.Manifest.GetManifest(path); //加载assetbundle AssetBundle ab = LoadAssetBundle(item.Path); if (ab != null) { var assetNames = ab.GetAllAssetNames(); string relname = ""; if (assetNames.Length == 1) { relname = assetNames[0]; } else { var f = path + "."; relname = assetNames.First((s) => s.Contains(f)); } return(ab.LoadAssetWithSubAssets <T>(relname)); } return(null); }
/// <summary> /// 降序排序 /// </summary> public TableQueryForILRuntime OrderByDesc(string field) { var query = ZString.Format(" Order By {0} Desc", field); this.@where = ZString.Concat(this.@where, query); return(this); }
public static string[] LostChallengeChapterRole_ParseGuide(int id, string str) { //EB.Debug.Log("LostChallengeChapterRole_ParseGuide: id -> {0}, str -> {1}", id, str); string[] ret; if (!string.IsNullOrEmpty(str)) { List <StringView> views; using (ZString.Block()) { ZString strID = ZString.Format("ID_scenes_lost_challenge_chapter_role_{0}_guide", id); string tmp = EB.Localizer.GetTableString(strID, str); StringView @string = new StringView(tmp); views = @string.Split2List('|'); } ret = new string[views.Count]; for (int i = 0; i < views.Count; i++) { ret[i] = views[i].ToString(); } if (ret.Length < 2) { EB.Debug.LogError("Error Role Config Guide need two string, role id = {0}", id); } else { return(ret); } } return(new string[2]); }
static GitRevision() { DotnetRuntime = ZString.Format("Runtime: {0} (Mode: {1}) ", RuntimeInformation.FrameworkDescription, Environment.Version.Major >= 6 && !RuntimeFeature.IsDynamicCodeSupported ? "NativeAOT" : "JIT" ); if (OperatingSystem.IsWindows()) { if (Environment.Is64BitOperatingSystem) { OSPlatform = "Win64"; } else { OSPlatform = "Win32"; } } else if (OperatingSystem.IsMacOS()) { OSPlatform = "macOS"; } else { OSPlatform = "Unix"; } #if DEBUG var buildConfiguration = "Debug"; #else var buildConfiguration = "Release"; #endif FullVersion = $"FelCore rev. {Hash} {Date} ({Branch} branch) ({OSPlatform}, {buildConfiguration})"; }
/// <summary> /// 仿MyBatis CRUD 更符合nameof规范 /// </summary> public TableQueryCustom WhereEqual(string where, object value) { var query = ZString.Format("{0} = {1}", where, value); this.@where = ZString.Concat(this.@where, " ", query); return(this); }
/// <summary> /// 升序排序 /// </summary> public TableQueryCustom OrderBy(string field) { var query = ZString.Format(" Order By {0}", field); this.@where = ZString.Concat(this.@where, query); return(this); }
/// <summary> /// 卸载 /// </summary> /// <param name="path">根据加载路径卸载</param> /// <param name="isForceUnload">强制卸载</param> public void UnloadAsset(string path, bool isForceUnload = false) { if (!this.loder.Manifest.IsHashName) { path = ZString.Format(RUNTIME, path); } var assetList = loder.Manifest.GetDependenciesByName(path); if (assetList == null) { return; } //卸载 for (int i = 0; i <= assetList.Count; i++) { var assetPath = assetList[i]; AssetBundleWapper abw = null; if (AssetbundleMap.TryGetValue(assetPath, out abw)) { if (isForceUnload) { abw.UnLoad(); } else { abw.Unuse(); } } } }
void Test <T0, T1>(string format, T0 t0, T1 t1) { var actual = ZString.Format(format, t0, t1); var expected = string.Format(format, t0, t1); actual.Should().Be(expected); }
public static void Assert <Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(bool condition, string message, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8) { if (!condition) { Trace.Assert(condition, ZString.Format(message, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)); Environment.Exit(1); // Ensure app exit on assertion failure when debugger attacked. } }
public static void Assert <Arg1, Arg2>(bool condition, string message, Arg1 arg1, Arg2 arg2) { if (!condition) { Trace.Assert(condition, ZString.Format(message, arg1, arg2)); Environment.Exit(1); // Ensure app exit on assertion failure when debugger attacked. } }
public void FormatArgs() { #if NETCOREAPP3_1 ZString.Format("{0:00000000}-{1:00000000}", 100, 200).Should().Be("00000100-00000200"); #else ZString.Format("{0:00000000}-{1:00000000}", 100, 200).Should().Be("100-200"); #endif }
/// <summary> /// In语句查询 /// </summary> public TableQueryCustom WhereIn(string field, params object[] objs) { var sqlIn = string.Join(",", objs); this.@where = ZString.Format("{0} {1} in ({2})", this.@where, field, sqlIn); return(this); }
public void Spaces() { var format = "Prime numbers less than 10: {00 , 01 }, {01 ,02 }, {2 ,3 :D }, {3 ,4: X }"; var expected = string.Format(format, 2, 3, 5, 7); var actual = ZString.Format(format, 2, 3, 5, 7); actual.Should().Be(expected); }
/// <summary> /// In语句查询 /// </summary> public TableQueryCustom WhereIn <T>(string field, IEnumerable <T> values) { var sqlIn = string.Join(",", values); this.@where = ZString.Format("{0} {1} in ({2})", this.@where, field, sqlIn); return(this); }
public void Escape() { TimeSpan span = new TimeSpan(12, 34, 56); var reference = string.Format(@"{0:h\,h\:mm\:ss}", span); var actual = ZString.Format(@"{0:h\,h\:mm\:ss}", span); actual.Should().Be(reference); }
public static void FEL_LOG_ERROR <Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(string filter, string message, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8) { #if !PERFORMANCE_PROFILING if (sLog.ShouldLog(filter, LOG_LEVEL_ERROR)) { sLog.outMessage(filter, LOG_LEVEL_ERROR, ZString.Format(message, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)); } #endif }
static void Run() { TimeSpan span = new TimeSpan(12, 34, 56); Console.WriteLine($"string.Format: {string.Format(@"{0:h\,h\:mm\:ss}", span)}"); Console.WriteLine($"ZString.Format: {ZString.Format(@"{0:h\,h\:mm\:ss}", span)}"); }
public static void FEL_LOG_WARN <Arg1>(string filter, string message, Arg1 arg1) { #if !PERFORMANCE_PROFILING if (sLog.ShouldLog(filter, LOG_LEVEL_WARN)) { sLog.outMessage(filter, LOG_LEVEL_WARN, ZString.Format(message, arg1)); } #endif }
public static void FEL_LOG_FATAL <Arg1, Arg2, Arg3>(string filter, string message, Arg1 arg1, Arg2 arg2, Arg3 arg3) { #if !PERFORMANCE_PROFILING if (sLog.ShouldLog(filter, LOG_LEVEL_FATAL)) { sLog.outMessage(filter, LOG_LEVEL_FATAL, ZString.Format(message, arg1, arg2, arg3)); } #endif }
public static void FEL_LOG_INFO <Arg1, Arg2, Arg3, Arg4>(string filter, string message, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) { #if !PERFORMANCE_PROFILING if (sLog.ShouldLog(filter, LOG_LEVEL_INFO)) { sLog.outMessage(filter, LOG_LEVEL_INFO, ZString.Format(message, arg1, arg2, arg3, arg4)); } #endif }
public void Flags() { ZString.Format("{0}", FlagsEnum.Abc | FlagsEnum.Bcd).Should().Be("Abc, Bcd"); ZString.Format("{0}", FlagsEnum.None).Should().Be("None"); ZString.Format("{0}", FlagsEnum.Efg).Should().Be("Efg"); Utf8(FlagsEnum.Abc | FlagsEnum.Bcd); Utf8(FlagsEnum.None); Utf8(FlagsEnum.Efg); }
/// <inheritdoc/> public string FormatToLink(TypeWithComment thisType, EventInfoWithComment evt, string?displayFormat = null, string?anchorFormat = null) { string?fmt = anchorFormat ?? EventAnchorDefaultFormat; TypeWithComment declaringType = evt.GetDeclaringTypeInfo(); if (object.Equals(thisType, declaringType) || evt.Info.DeclaringType.IsAssignableFrom(thisType.Info) || declaringType.Comment.IsEmpty) { string anchor = evt.Info.Name; string displayText; if (string.IsNullOrEmpty(displayFormat)) { displayText = System.Web.HttpUtility.HtmlEncode(anchor); } else { displayText = ZString.Format(displayFormat, System.Web.HttpUtility.HtmlEncode(anchor)); } if (string.IsNullOrEmpty(fmt)) { return(ZString.Format("[{0}](#{1})", displayText, ToAnchor(anchor))); } else { return(ZString.Format("[{0}](#{1})", displayText, ToAnchor(ZString.Format(fmt, anchor)))); } } else { string anchor = ZString.Concat(declaringType.Info.FormatToReadableTypeName(false), ".", evt.Info.Name); string displayText; if (string.IsNullOrEmpty(displayFormat)) { displayText = System.Web.HttpUtility.HtmlEncode(anchor); } else { displayText = ZString.Format(displayFormat, System.Web.HttpUtility.HtmlEncode(anchor)); } string typeLink = ZString.Format("../{1}/{2}.md", FormatToReadableName(declaringType, false), declaringType.Namespace, declaringType.Name); if (string.IsNullOrEmpty(fmt)) { return(ZString.Format("[{0}]({1}#{2})", displayText, typeLink, ToAnchor(anchor))); } else { return(ZString.Format("[{0}]({1}#{2})", displayText, typeLink, ToAnchor(ZString.Format(fmt, anchor)))); } } }
public static void FEL_LOG_WARN <Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(string filter, string message, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6) { #if !PERFORMANCE_PROFILING if (sLog.ShouldLog(filter, LOG_LEVEL_WARN)) { sLog.outMessage(filter, LOG_LEVEL_WARN, ZString.Format(message, arg1, arg2, arg3, arg4, arg5, arg6)); } #endif }
public void Standard() { ZString.Format("{0}", StandardEnum.Abc).Should().Be("Abc"); ZString.Format("{0}", StandardEnum.Def).Should().Be("Def"); ZString.Format("{0}", StandardEnum.Ghi).Should().Be("Ghi"); Utf8(StandardEnum.Abc); Utf8(StandardEnum.Def); Utf8(StandardEnum.Ghi); }
public static void FEL_LOG_ERROR <Arg1, Arg2>(string filter, string message, Arg1 arg1, Arg2 arg2) { #if !PERFORMANCE_PROFILING if (sLog.ShouldLog(filter, LOG_LEVEL_ERROR)) { sLog.outMessage(filter, LOG_LEVEL_ERROR, ZString.Format(message, arg1, arg2)); } #endif }
/// <summary> /// Where语句 /// </summary> /// <param name="where"></param> /// <returns></returns> public TableQueryCustom Where(string where, object value) { if (value is string) { value = ZString.Format("'{0}'", value); } this.@where = ZString.Concat(this.@where, " ", ZString.Format(where, value)); return(this); }
public static void DebugAssert <Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(bool condition, string message, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6) { if (!condition) { Trace.Assert(condition, ZString.Format(message, arg1, arg2, arg3, arg4, arg5, arg6)); #if DEBUG Environment.Exit(1);; // Ensure app exit on assertion failure when debugger attacked. #endif } }
public void Duplicate() { ZString.Format("{0}", DuplicateEnum.A).Should().Be("A"); ZString.Format("{0}", DuplicateEnum.B).Should().Be("B"); ZString.Format("{0}", DuplicateEnum.BB).Should().Be("B"); ZString.Format("{0}", DuplicateEnum.C).Should().Be("C"); Utf8(DuplicateEnum.A); Utf8(DuplicateEnum.B); Utf8(DuplicateEnum.BB); Utf8(DuplicateEnum.C); }
/// <summary> /// ZString,Format,不断重用之前char的位置,从而节省空间,这个方法只能在当前帧下次ZString.Format之前,保证返回的string不会变,一般只能用于临时计算,不能缓存 /// </summary> /// <param name="format"></param> /// <param name="args"></param> /// <returns></returns> public static string Format(string format, params object[] args) { if (!format.Contains("{") || !format.Contains("}")) { return(format); } using (ZString.Block()) { if (args != null && args.Length > 0) { ZString @string = format; if (args.Length == 1) { @string = ZString.Format(format, GetString(args[0])); } else if (args.Length == 2) { @string = ZString.Format(format, GetString(args[0]), GetString(args[1])); } else if (args.Length == 3) { @string = ZString.Format(format, GetString(args[0]), GetString(args[1]), GetString(args[2])); } else if (args.Length == 4) { @string = ZString.Format(format, GetString(args[0]), GetString(args[1]), GetString(args[2]), GetString(args[3])); } else if (args.Length == 5) { @string = ZString.Format(format, GetString(args[0]), GetString(args[1]), GetString(args[2]), GetString(args[3]), GetString(args[4])); } else if (args.Length == 6) { @string = ZString.Format(format, GetString(args[0]), GetString(args[1]), GetString(args[2]), GetString(args[3]), GetString(args[4]), GetString(args[5])); } else if (args.Length == 7) { @string = ZString.Format(format, GetString(args[0]), GetString(args[1]), GetString(args[2]), GetString(args[3]), GetString(args[4]), GetString(args[5]), GetString(args[6])); } else if (args.Length == 8) { @string = ZString.Format(format, GetString(args[0]), GetString(args[1]), GetString(args[2]), GetString(args[3]), GetString(args[4]), GetString(args[5]), GetString(args[6]), GetString(args[7])); } else if (args.Length == 9) { @string = ZString.Format(format, GetString(args[0]), GetString(args[1]), GetString(args[2]), GetString(args[3]), GetString(args[4]), GetString(args[5]), GetString(args[6]), GetString(args[7]), GetString(args[8])); } args = null; return(@string); } return(format); } }