Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public ModelInfo CreateModelInfo(Type type, TypeMetaData metaData)
        {
            var modelInfo = GetModelInfoFromCache(type);

            if (modelInfo == null)
            {
                modelInfo = CreateNewModelInfo(type, metaData);

                SetModelInfoIntoCache(type, modelInfo);
            }

            return modelInfo;
        }
Ejemplo n.º 3
0
        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.");
        }
Ejemplo n.º 4
0
 internal ModelInfo(RuntimeTypeModel model, TypeMetaData metaData)
 {
     Model = model;
     MetaData = metaData;
 }