private ModelInfo CreateNewModelInfo(Type type, TypeMetaData metaData, ModeType appMode) { var modelGenerator = metaData == null ? new ProtoBufModelGenerator(type) : new ProtoBufModelGenerator(type, metaData); var modelInfo = modelGenerator.ConfigureType(type, true, true, appMode); return modelInfo; }
public ModelInfo CreateModelInfo(Type type, TypeMetaData metaData, ModeType appMode) { var modelInfo = GetModelInfoFromCache(type, appMode); if (modelInfo == null) { modelInfo = CreateNewModelInfo(type, metaData, appMode); SetModelInfoIntoCache(type, modelInfo, appMode); } return modelInfo; }
internal ModelInfo(RuntimeTypeModel model, TypeMetaData metaData) { Model = model; MetaData = metaData; }
public void TestMetaDataSerialization() { var metaData = new TypeMetaData(); metaData.StoreFieldNumber("blah/", "myName", "someField", 2); var serializer = ObjectBuilder.GetSerializer(); var result = serializer.Serialize(metaData, AppModeType); 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, AppModeType); 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."); }
private static string ConvertToJson(TypeMetaData metaData) { return JsonSerializer.ConvertToJson(metaData); }
public ProtoBufModelGenerator(Type type, TypeMetaData typeMetaData) { _targetType = type; _typeMetaData = typeMetaData; _usePreDefinedFieldNumbers = true; }
public ProtoBufModelGenerator(Type type) { _targetType = type; _typeMetaData = new TypeMetaData(); _usePreDefinedFieldNumbers = false; }