public ushort GetOrAdd(string value) { if (value == null) { return(0); } if (_string2Index.TryGetValue(value, out ushort result)) { return(result); } result = ++_currentIndex; _index2String[result] = value; Utf8String utf8String = UnsafeStringContainer.GetString(value, _quote); _index2Bytes[result] = utf8String; _utf82index.Add(utf8String, result); _string2Index.Add(value, result); _index2Accounts[result] = new HList <uint>(); return(result); }
public static void Main() { HDict <ConcreteJsonWriteRelation> dict = new HDict <ConcreteJsonWriteRelation>(); JsonWrite0 <int, ConcreteJsonWriteRelation> w = new IntJsonWrite2 <ConcreteJsonWriteRelation>(); HDict <ConcreteJsonWriteRelation> dict2 = dict.Add(new Type <int>(), w); Console.WriteLine(1.ToJsonString(dict)); Console.WriteLine(true.ToJsonString(dict)); Console.WriteLine(ListType.To(new List <int> { 1, 2, 3 }).ToJsonString(dict2)); Console.WriteLine(new MyStruct(123, false).ToJsonString(dict)); // compile time error! // Console.WriteLine( "hoge".ToJsonString(dict) ); }