/// <summary> /// Defines custom fields in the value factory so that the importer /// can find them. /// </summary> /// <param name="type"></param> /// <param name="class2type"></param> public static void Init(XType type, Class2TypeMap class2type) { Field field = type.GetField(FIELD_NAME); class2type.Add(typeof(StrStrHashMap), type); type.SetComponentType(typeof(StrStrHashMap)); type.SetImportExportHelper(new StrStrHashMapSerializer(type, field)); type.PutValidator(field, Validator_object.Get(1)); type.Lock(); }
/// <summary> /// Defines custom fields in the value factory so that the importer /// can find them. /// </summary> /// <param name="type"></param> /// <param name="class2type"></param> public static void Init(XType type, Class2TypeMap class2type) { Field field = type.GetField(FIELD_NAME); /* class2type.Add( typeof( List<object> ), type ); * type.SetClass(typeof(List<object>)); */ class2type.Add(typeof(ArrayList), type); type.SetComponentType(typeof(ArrayList)); type.SetImportExportHelper(new ListSerializer(type, field)); type.PutValidator(field, Validator_object.Get(1)); type.Lock(); }
/// <summary> /// Defines custom fields in the value factory so that the importer /// can find them. /// </summary> /// <param name="type"></param> /// <param name="class2type"></param> public static void Init(XType type, Class2TypeMap class2type) { Field field = type.GetField(FIELD_NAME); /* class2type.Add( typeof( Dictionary<object,object> ), type ); * type.SetClass(typeof(Dictionary<object, object>)); */ class2type.Add(typeof(Hashtable), type); type.SetComponentType(typeof(Hashtable)); type.SetImportExportHelper(new MapSerializer(type, field)); type.PutValidator(field, Validator_object.Get(1)); type.Lock(); }
private void assertValueToBytes(Object value, sbyte[] expectedBytes) { XType t = new XType(1, "a"); Field f = new Field(2, "b"); t.PutValidator(f, Validator_object.Get(0)); Message msg = new Message(t, vf); msg.Add(f, value); BinaryTaggedDataOutput btdo = new BinaryTaggedDataOutput(vf, "none:"); FlexBuffer buf = new FlexBuffer(); btdo.WriteMessage(msg, buf); buf.SetIndex(0); byte[] b = buf.GetAvailBytes(); sbyte[] b1 = new sbyte[b.Length]; Buffer.BlockCopy(b, 0, b1, 0, b.Length); Dump(b); AssertArrayEquals(expectedBytes, b1); }
private void ReadKeysAndValues(StructValue sv) { XType t = sv.GetXType; while (true) { Field key = ReadField(t); if (key == null) { break; } //Object obj = ReadValue( intValidator, true ); //if ( obj == NONE ) // break; //int id = ( int ) obj; //Field key = t.GetField( id ); //if (key == null) // key = new Field(id, id.ToString()); Validator v = t.GetValidator(key); if (v != null) { sv.Add(key, ReadValue(v)); } else { // read the value but ignore it. Object obj = ReadValue(Validator_object.Get(0)); if (false) { sv.Add(key, obj); } } } }