Example #1
0
        static public bool TryParse(StringSlice inSlice, out StringHash64 outHash)
        {
            if (inSlice.StartsWith(StringHashing.CustomHashPrefix))
            {
                ulong hexVal;
                if (StringParser.TryParseHex(inSlice.Substring(1), 16, out hexVal))
                {
                    outHash = new StringHash64(hexVal);
                    return(true);
                }
            }
            else if (inSlice.StartsWith("0x"))
            {
                ulong hexVal;
                if (StringParser.TryParseHex(inSlice.Substring(2), 16, out hexVal))
                {
                    outHash = new StringHash64(hexVal);
                    return(true);
                }

                outHash = default(StringHash64);
                return(false);
            }
            else if (inSlice.StartsWith(StringHashing.StringPrefix))
            {
                outHash = inSlice.Substring(1).Hash64();
                return(true);
            }
            else if (inSlice.StartsWith('"') && inSlice.EndsWith('"'))
            {
                outHash = inSlice.Substring(1, inSlice.Length - 2).Hash64();
                return(true);
            }

            outHash = inSlice.Hash64();
            return(true);
        }