///////////////////// // UTILITY METHODS // ///////////////////// private void checkType(XType type, params Field[] fields) { Assert.IsNotNull(type); Assert.AreSame(typeof(XType), type.GetType()); Assert.AreSame(type, vf.GetType(type.Id)); List <Field> tfields = type.GetFields(); if (fields != null) { Assert.AreEqual(fields.Length, tfields.Count); //for (Field f: fields) for (int i = 0; i < fields.Length; i++) { Assert.IsNotNull(type.GetValidator(fields[i])); Assert.AreSame(fields[i], type.GetField(fields[i].Id)); Assert.AreSame(fields[i], type.GetField(fields[i].Name)); } } else { Assert.AreEqual(0, tfields.Count); } }
private Field ReadField(XType type) { Object obj = ReadValue(intOrStrValidator, true); if (obj == NONE) { return(null); } if (obj is int) { int id = (int)obj; Field field = type.GetField(id); if (field == null) { field = new Field(id, id.ToString()); } return(field); } String name = (String)obj; Field nfield = type.GetField(name); if (nfield == null) { nfield = new Field(name); } return(nfield); }
/// <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(DateTime), type); type.SetComponentType(typeof(DateTime)); type.SetImportExportHelper(new DateSerializer(type, field)); type.PutValidator(field, Validator_long.Get(0)); 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(StrStrHashMap), type); type.SetComponentType(typeof(StrStrHashMap)); type.SetImportExportHelper(new StrStrHashMapSerializer(type, field)); type.PutValidator(field, Validator_object.Get(1)); type.Lock(); }
public static void Init(XType type, Class2TypeMap class2type) { Field field = type.GetField(FIELD_NAME); class2type.Add(typeof(_Etch_RuntimeException), type); type.SetComponentType(typeof(_Etch_RuntimeException)); type.SetImportExportHelper(new RuntimeExceptionSerializer(type, field)); type.PutValidator(field, Validator_string.Get(0)); 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(); }
/// <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(); }
public void GetField_locked() { XType type = new XType("blah"); Assert.IsNotNull(type.GetField("a")); Assert.IsNotNull(type.GetField("b")); type.Lock(); Assert.IsNotNull(type.GetField("a")); Assert.IsNotNull(type.GetField("b")); Assert.IsNull(type.GetField("x")); Assert.IsNull(type.GetField("y")); }