///////////////////// // 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 void WriteKeysAndValues(StructValue sv) { XType t = sv.GetXType; foreach (KeyValuePair <Field, Object> me in sv) { Field f = me.Key; WriteField(f); WriteValue(t.GetValidator(f), me.Value); } }
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); } } } }