예제 #1
0
        public void TestImport1()
        {
            StrIntHashMap map = new StrIntHashMap();

            map.Add("a", 1);
            TestMap(map);
        }
예제 #2
0
        public void TestImportNull1()
        {
            StrIntHashMap map = new StrIntHashMap();

            map.Add("a", 1);
            map.Add("b", null);
            map.Add("c", 2);
            TestMap(map);
        }
예제 #3
0
        // 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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        public void TestImport0()
        {
            StrIntHashMap map = new StrIntHashMap();

            TestMap(map);
        }
예제 #7
0
 /// <summary>
 /// Constructs a StrIntHashMap initialized from another
 /// </summary>
 /// <param name="other"></param>
 public StrIntHashMap(StrIntHashMap other)
     : base(other)
 {
 }