private ModelInfo CreateNewModelInfo(Type type, TypeMetaData metaData) { var modelGenerator = metaData == null ? new ProtoBufModelGenerator(type) : new ProtoBufModelGenerator(type, metaData); var modelInfo = modelGenerator.ConfigureType(type, true, true); return modelInfo; }
public ModelInfo CreateModelInfo(Type type, TypeMetaData metaData) { var modelInfo = GetModelInfoFromCache(type); if (modelInfo == null) { modelInfo = CreateNewModelInfo(type, metaData); SetModelInfoIntoCache(type, modelInfo); } return modelInfo; }
public void TestMetaDataSerialization() { var metaData = new TypeMetaData(); metaData.StoreFieldNumber("blah/", "myName", "someField", 2); var serializer = ObjectBuilder.GetSerializer(); var result = serializer.Serialize(metaData); Assert.IsTrue(result.Data.Length > 0, "Meta data was not successfully serialized. The resultant byte count was zero."); var deserialized = serializer.Deserialize<TypeMetaData>(result.Data); Assert.IsNotNull(deserialized, "Deserialization was not succesfull, the resultant object was null."); int? fieldNumber; var success = deserialized.GetFieldNumber("blah/", "myName", "someField", out fieldNumber); Assert.IsTrue(success, "The expected field number was not found in the deserialized data. MetaData deserialization failed."); Assert.AreEqual(2, fieldNumber.Value, "The expected field number was not found in the deserialized data. MetaData deserialization failed."); }
internal ModelInfo(RuntimeTypeModel model, TypeMetaData metaData) { Model = model; MetaData = metaData; }