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