public void TestImport1() { StrStrHashMap map = new StrStrHashMap(); map.Add("a", "1"); TestMap(map); }
public void TestImport3() { StrStrHashMap map = new StrStrHashMap(); map.Add("a", "1"); map.Add("b", "2"); map.Add("c", "3"); TestMap(map); }
public override Object ImportValue(StructValue sv) { StrStrHashMap map = new StrStrHashMap(); Object[] keysAndValues = ( Object[] )sv.Get(field); int n = keysAndValues.Length; int index = 0; while (index < n) { String key = ( String )keysAndValues[index++]; String value = ( String )keysAndValues[index++]; map.Add(key, value); } return(map); }
// no tests for null keys as string? isn't allowed public void TestMap(StrStrHashMap map) { XType type = new XType("map"); Class2TypeMap class2type = new Class2TypeMap(); StrStrHashMapSerializer.Init(type, class2type); ImportExportHelper helper = type.GetImportExportHelper(); StructValue sv = helper.ExportValue(vf, map); Assert.AreEqual(sv.GetXType, type); StrStrHashMap map2 = (StrStrHashMap)helper.ImportValue(sv); Assert.AreEqual(map, map2); }
public override StructValue ExportValue(ValueFactory vf, Object value) { StrStrHashMap map = ( StrStrHashMap )value; Object[] keysAndValues = new Object[map.Count * 2]; int index = 0; foreach (KeyValuePair <String, String> me in map) { keysAndValues[index++] = me.Key; keysAndValues[index++] = me.Value; } StructValue sv = new StructValue(type, vf); sv.Add(field, keysAndValues); return(sv); }
public void TestImport0() { StrStrHashMap map = new StrStrHashMap(); TestMap(map); }
/// <summary> /// Constructs a StrStrHashMap initialized from another /// </summary> /// <param name="other"></param> public StrStrHashMap(StrStrHashMap other) : base(other) { }