public override void ToString(System.Text.StringBuilder builder) { builder.AppendLine("Connection token: " + this.Token); builder.AppendFormatLine("Unknown uint64: {0} 0x{0:X16}", this.UnknownULong); builder.AppendLine("Connection index: " + this.ConnectionIndex); builder.AppendFormatLine("Connection server: {0}:{1}", this.IP, this.Port); builder.AppendLine("Computed Hash: " + this.ComputedHash.ToHexString()); builder.AppendLine("Server's Hash: " + this.ServerHash.ToHexString()); }
public static void LogInfo(string key, MonoXIL.Collections.Generic.Collection <Instruction> Instructions) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendFormatLine("{0} Total:{1}", key, Instructions.Count); for (int i = 0; i < Instructions.Count; ++i) { sb.AppendFormatLine("{0}){1}", i, Instructions[i].ToString()); } UnityEngine.Debug.Log(sb.ToString()); }
public void Log() { var sb = new System.Text.StringBuilder(); sb.AppendLine("Stopwatches:"); var tagLenMax = 3; var callsMax = 5; foreach (var kv in dic) { var tag = kv.Key; var calls = kv.Value.calls; tagLenMax = (tag.Length > tagLenMax) ? tag.Length : tagLenMax; callsMax = (calls > callsMax) ? calls : callsMax; } var callsMaxDigits = UnityEngine.Mathf.Max(5, Util.GetDigits(callsMax)); sb.AppendFormatLine( " {0,-" + tagLenMax + "}|Calls, Time(sec), Ave(sec), Min(sec), Max(sec)", "Tag"); var sorted = dic.OrderBy((x) => x.Key); foreach (var kv in sorted) { var tag = kv.Key; var val = kv.Value; if (val.calls == 0) { // Start()後、Stop()前にLog()を呼んだ時はここに来る. continue; } var sw = val.sw; if (sw.IsRunning) { UnityEngine.Debug.LogWarning("@Stopwatches.Log() tag:\"" + tag + "\" is running!"); } sb.AppendFormatLine( " {0,-" + tagLenMax + "}|{1," + callsMaxDigits + "}, {2:f7}, {3:f7}, {4:f7}, {5:f7}", tag, val.calls, val.totalSec, val.totalSec / val.calls, val.minSec, val.maxSec); } UnityEngine.Debug.LogWarning(sb.ToString()); }
//[UnityEditor.MenuItem("XIL/RefType优化")] static void RefTypeOpt() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendFormatLine("namespace wxb"); sb.AppendFormatLine("{{"); sb.AppendFormatLine(" public partial class RefType"); sb.AppendFormatLine(" {{"); Name(sb, "InvokeMethod", false); sb.AppendLine(); Name(sb, "InvokeMethodReturn", true); sb.AppendLine(); Name(sb, "TryInvokeMethod", false); sb.AppendLine(); Name(sb, "TryInvokeMethodReturn", true); sb.AppendLine(); sb.AppendFormatLine(" }}"); sb.AppendFormatLine("}}"); string filename = "Assets/XIL/Scripts/RefType_InvokeMethod.cs"; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } System.IO.File.WriteAllText(filename, sb.ToString()); UnityEditor.AssetDatabase.ImportAsset(filename); }
static void Name(System.Text.StringBuilder sb, string name, bool isReturn) { for (int i = 0; i < 11; ++i) { if (i == 0) { sb.AppendFormatLine(" public {0} {1}(string name)", isReturn ? "object" : "void", name); sb.AppendFormatLine(" {{"); sb.AppendFormatLine(" using (var obj = new global::IL.EmptyObjs())"); sb.AppendFormatLine(" {{"); if (isReturn) { sb.AppendFormatLine(" return {0}(name, obj.objs);", name); } else { sb.AppendFormatLine(" {0}(name, obj.objs);", name); } sb.AppendFormatLine(" }}"); sb.AppendFormatLine(" }}"); } else { sb.AppendFormat(" public {0} {1}(string name", isReturn ? "object" : "void", name); for (int j = 0; j < i; ++j) { sb.AppendFormat(", object p{0}", j); } sb.AppendLine(")"); sb.AppendFormatLine(" {{"); sb.AppendFormat(" using (var obj = new global::IL.Objects("); for (int j = 0; j < i; ++j) { if (j == 0) { sb.AppendFormat("p{0}", j); } else { sb.AppendFormat(", p{0}", j); } } sb.AppendLine("))"); sb.AppendFormatLine(" {{"); if (isReturn) { sb.AppendFormatLine(" return {0}(name, obj.objs);", name); } else { sb.AppendFormatLine(" {0}(name, obj.objs);", name); } sb.AppendFormatLine(" }}"); sb.AppendFormatLine(" }}"); } } }