Ejemplo n.º 1
0
 public void Serialize(BaseReflectionModel t, string fileName)
 {
     using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
     {
         XMLReflectionModel     xmlModel   = _mapper.Map <XMLReflectionModel>(t);
         DataContractSerializer serializer = new DataContractSerializer(typeof(XMLReflectionModel));
         serializer.WriteObject(fileStream, xmlModel);
     }
 }
Ejemplo n.º 2
0
        public void Serialize(BaseReflectionModel model, string fileName)
        {
            ClearDB();
            DbReflectionModel dbModel = _mapper.Map <DbReflectionModel>(model);

            dbModel.Name = "DbAssemblyModel";
            Context.AssemblyModels.Add(dbModel);
            Context.SaveChanges();
        }
Ejemplo n.º 3
0
        public void ReflectionSerializationDeserializationNameTest()
        {
            XMLSerializer       serializer = new XMLSerializer();
            BaseReflectionModel model      = new BaseReflectionModel();

            model.Name = "TestName";

            serializer.Serialize(model, "test1model.xml");
            BaseReflectionModel deserialized = serializer.Deserialize("test1model.xml");

            Assert.IsTrue(deserialized != null);
            Assert.AreEqual(model.Name, deserialized.Name);
        }
Ejemplo n.º 4
0
        public void ReflectionSerializationDeserializationNamespacesTest()
        {
            XMLSerializer       serializer = new XMLSerializer();
            BaseReflectionModel model      = new BaseReflectionModel();

            model.Namespaces = new System.Collections.Generic.List <BaseNamespaceModel> {
                new BaseNamespaceModel(),
                new BaseNamespaceModel(), new BaseNamespaceModel()
            };

            serializer.Serialize(model, "test2model.xml");
            BaseReflectionModel deserialized = serializer.Deserialize("test2model.xml");

            Assert.IsTrue(deserialized != null);
            Assert.AreEqual(model.Namespaces.Count, deserialized.Namespaces.Count);
        }