public bool Parse(string format, out Comb result) { if (format == "X") { return(this.TryParseHex(out result)); } return(this.TryParse(format, out result)); }
private bool TryParseHex(out Comb result) { ulong a, b, c; result = new Comb(); if (!(this.ParseChar('{') && this.ParseHexPrefix() && this.ParseHex(8, false, out a) && this.ParseCharWithWhiteSpaces(',') && this.ParseHexPrefix() && this.ParseHex(4, false, out b) && this.ParseCharWithWhiteSpaces(',') && this.ParseHexPrefix() && this.ParseHex(4, false, out c) && this.ParseCharWithWhiteSpaces(',') && this.ParseCharWithWhiteSpaces('{'))) { return(false); } var d = new byte[8]; for (int i = 0; i < d.Length; ++i) { ulong dd; if (!(this.ParseHexPrefix() && this.ParseHex(2, false, out dd))) { return(false); } d[i] = (byte)dd; if (i != 7 && !this.ParseCharWithWhiteSpaces(',')) { return(false); } } if (!(this.ParseCharWithWhiteSpaces('}') && this.ParseCharWithWhiteSpaces('}'))) { return(false); } if (!this.EOF) { return(false); } result = new Comb((int)a, (short)b, (short)c, d); return(true); }
public bool Parse(out Comb result) { var format = String.Empty; switch (this.sourceLength) { case 32: format = "N"; break; case 36: format = "D"; break; case 38: switch (this.source[0]) { case '{': format = "B"; break; case '(': format = "P"; break; } break; } if (this.TryParse(format, out result)) { return(true); } this.Reset(); return(this.TryParseHex(out result)); }
private bool TryParse(string format, out Comb result) { result = new Comb(); if ((format == "B" && !this.ParseChar('{')) || (format == "P" && !this.ParseChar('('))) { return(false); } if (!this.ParseHex(8, true, out var a)) { return(false); } var hasHyphen = FormatHasHyphen(format); if (hasHyphen && !this.ParseChar('-')) { return(false); } if (!this.ParseHex(4, true, out var b)) { return(false); } if (hasHyphen && !this.ParseChar('-')) { return(false); } if (!this.ParseHex(4, true, out var c)) { return(false); } if (hasHyphen && !this.ParseChar('-')) { return(false); } var d = new byte[8]; for (var i = 0; i < d.Length; i++) { if (!this.ParseHex(2, true, out var dd)) { return(false); } if (i == 1 && hasHyphen && !this.ParseChar('-')) { return(false); } d[i] = (byte)dd; } if ((format == "B" && !this.ParseChar('}')) || (format == "P" && !this.ParseChar(')'))) { return(false); } if (!this.EOF) { return(false); } result = new Comb((int)a, (short)b, (short)c, d); return(true); }