From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/SubString.cs | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Client/Assembly-CSharp/SubString.cs (limited to 'Client/Assembly-CSharp/SubString.cs') diff --git a/Client/Assembly-CSharp/SubString.cs b/Client/Assembly-CSharp/SubString.cs new file mode 100644 index 0000000..6270112 --- /dev/null +++ b/Client/Assembly-CSharp/SubString.cs @@ -0,0 +1,77 @@ +using System; + +public struct SubString +{ + public readonly int Start; + + public readonly int Length; + + public readonly string Source; + + public SubString(string source, int start, int length) + { + this.Source = source; + this.Start = start; + this.Length = length; + } + + public override string ToString() + { + return this.Source.Substring(this.Start, this.Length); + } + + public int GetKvpValue() + { + int num = this.Start + this.Length; + for (int i = this.Start; i < num; i++) + { + if (this.Source[i] == '=') + { + i++; + return new SubString(this.Source, i, num - i).ToInt(); + } + } + throw new InvalidCastException(); + } + + public int ToInt() + { + int num = 0; + int num2 = this.Start + this.Length; + bool flag = false; + for (int i = this.Start; i < num2; i++) + { + char c = this.Source[i]; + if (c == '-') + { + flag = true; + } + else if (c >= '0' && c <= '9') + { + int num3 = (int)(c - '0'); + num = 10 * num + num3; + } + } + if (!flag) + { + return num; + } + return -num; + } + + public bool StartsWith(string v) + { + if (v.Length > this.Length) + { + return false; + } + for (int i = 0; i < v.Length; i++) + { + if (this.Source[i + this.Start] != v[i]) + { + return false; + } + } + return true; + } +} -- cgit v1.1-26-g67d0