public ProjectImporter(string apiFormat)
 {
     _apiFormat       = apiFormat;
     _serializer      = SerializerFactory.Get(apiFormat);
     _commonImporter  = new CommonImporter(RedmineResources.Projects, _apiFormat);
     _downloadManager = new DownloadManager();
 }
Exemple #2
0
        public void Can_Soap_Serializer_String()
        {
            var bs = SerializerFactory.Get("soap");

            var foo1 = TestHelper.GetFoo();

            var str = bs.SerializeToString(foo1);

            var foo2 = bs.DeserializeFromString <Foo>(str);

            Assert.True(TestHelper.Equal(foo1, foo2));
        }
Exemple #3
0
        public void Can_DataContract_Serializer_String()
        {
            var bs = SerializerFactory.Get("dc");

            var foo1 = TestHelper.GetFoo();

            var str = bs.SerializeToString(foo1);

            var foo2 = (Foo)bs.DeserializeFromString(str, (typeof(Foo)));

            Assert.True(TestHelper.Equal(foo1, foo2));
        }
        public void Can_Xml_Serializer_String()
        {
            var bs = SerializerFactory.Get("xml");

            var foo1 = TestHelper.GetFoo();

            var str = bs.SerializeToString(foo1);

            var foo2 = bs.DeserializeFromString(str, (typeof(Foo)));

            Assert.Equal(foo1.ToString(), foo2.ToString());
        }
        public void Can_NET_Serializer_String()
        {
            var bs = SerializerFactory.Get("NET");

            var foo1 = TestHelper.GetFoo();

            var str = bs.SerializeToString(foo1);

            var foo2 = bs.DeserializeFromString <Foo>(str);

            Assert.Equal(foo1.ToString(), foo2.ToString());
        }
        public void Can_TextJson_Serializer_String()
        {
            var bs = SerializerFactory.Get("textJson");

            var foo1 = TestHelper.GetFoo();

            var str = bs.SerializeToString(foo1);

            var foo2 = (Foo)bs.DeserializeFromString(str, typeof(Foo));

            Assert.True(TestHelper.Equal(foo1, foo2));
        }
        public void Can_NET_Serializer_Bytes()
        {
            var bs = SerializerFactory.Get("NET");

            var foo1 = TestHelper.GetFoo();

            byte[] output;
            bs.Serialize(foo1, out output);

            var foo2 = bs.Deserialize <Foo>(output);

            Assert.Equal(foo1.ToString(), foo2.ToString());
        }
        public void Can_TextJson_Serializer_Bytes()
        {
            var bs = SerializerFactory.Get("textJson");

            var foo1 = TestHelper.GetFoo();

            byte[] output;
            bs.Serialize(foo1, out output);

            var foo2 = (Foo)bs.Deserialize(output, typeof(Foo));

            Assert.True(TestHelper.Equal(foo1, foo2));
        }
        public void Can_Binary_Serializer_Bytes()
        {
            var bs = SerializerFactory.Get("binary");

            var foo1 = TestHelper.GetFoo();

            byte[] output;
            bs.Serialize(foo1, out output);

            var foo2 = bs.Deserialize <Foo>(output);

            Assert.True(TestHelper.Equal(foo1, foo2));
        }
        public void Can_ProtoBuf_Serializer_Bytes()
        {
            var bs = SerializerFactory.Get("ProtoBuf");

            var foo1 = TestHelper.GetFoo();

            byte[] output;
            bs.Serialize(foo1, out output);

            var foo2 = bs.Deserialize(output, typeof(Foo));

            Assert.Equal(foo1.ToString(), foo2.ToString());
        }
        public void Can_TextJson_Serializer_Writer_And_Reader()
        {
            var bs   = SerializerFactory.Get("textJson");
            var foo1 = TestHelper.GetFoo();

            StringWriter sw = new StringWriter();

            bs.Serialize(foo1, sw);

            StringReader sr = new StringReader(sw.ToString());

            var foo2 = (Foo)bs.Deserialize(sr, typeof(Foo));

            Assert.True(TestHelper.Equal(foo1, foo2));
        }
        public void Can_ProtoBuf_Serializer_Writer_And_Reader()
        {
            var bs   = SerializerFactory.Get("ProtoBuf");
            var foo1 = TestHelper.GetFoo();

            StringWriter sw = new StringWriter();

            bs.Serialize(foo1, sw);

            StringReader sr = new StringReader(sw.ToString());

            var foo2 = bs.Deserialize(sr, typeof(Foo));

            Assert.Equal(foo1.ToString(), foo2.ToString());
        }
        public void Can_NET_Serializer_Writer_And_Reader()
        {
            var bs   = SerializerFactory.Get("NET");
            var foo1 = TestHelper.GetFoo();

            StringWriter sw = new StringWriter();

            bs.Serialize(foo1, sw);

            StringReader sr = new StringReader(sw.ToString());

            var foo2 = bs.Deserialize <Foo>(sr);

            Assert.Equal(foo1.ToString(), foo2.ToString());
        }
Exemple #14
0
        public void Can_DataContract_Serializer_Stream()
        {
            var bs = SerializerFactory.Get("dc");

            var    foo1   = TestHelper.GetFoo();
            Stream output = new MemoryStream();

            bs.Serialize(foo1, output);

            output.Position = 0;
            var foo2 = bs.Deserialize(output, typeof(Foo));

            output.Dispose();

            Assert.Equal(foo1.ToString(), foo2.ToString());
        }
        public void Can_Binary_Serializer_Stream()
        {
            var bs = SerializerFactory.Get("binary");

            var    foo1   = TestHelper.GetFoo();
            Stream output = new MemoryStream();

            bs.Serialize(foo1, output);

            output.Position = 0;
            var foo2 = bs.Deserialize <Foo>(output);

            output.Dispose();

            Assert.True(TestHelper.Equal(foo1, foo2));
        }
        public void Can_TextJson_Serializer_Stream()
        {
            var bs = SerializerFactory.Get("textJson");

            var    foo1   = TestHelper.GetFoo();
            Stream output = new MemoryStream();

            bs.Serialize(foo1, output);

            output.Position = 0;
            var foo2 = (Foo)bs.Deserialize(output, typeof(Foo));

            output.Dispose();

            Assert.True(TestHelper.Equal(foo1, foo2));
        }
        public void Can_NET_Serializer_Stream()
        {
            var bs = SerializerFactory.Get("NET");

            var    foo1   = TestHelper.GetFoo();
            Stream output = new MemoryStream();

            bs.Serialize(foo1, output);

            output.Position = 0;
            var foo2 = bs.Deserialize <Foo>(output);

            output.Dispose();

            Assert.Equal(foo1.ToString(), foo2.ToString());
        }
Exemple #18
0
 public void Can_soap_deep_clone()
 {
     Test_Deep_Clone(SerializerFactory.Get("soap"));
 }
Exemple #19
0
        private T Deserialize <T>(String value)
        {
            var serializer = SerializerFactory.Get <T>(this.Options);

            return(serializer.Deserialize(value));
        }
Exemple #20
0
        private void CompareDeserializes <T>(T obj, int runs)
        {
            var objType = obj.GetType();

            //warm-up

            byte[] protobufData, binaryData, dataContractData, soapData, netData;

#if NETFULL || NETCOREAPP3_1
            var jilSerializedText = jilserializer.SerializeToString(obj);
            using (MemoryStream mem = new MemoryStream())
            {
                binaryserializer.Serialize(obj, mem);
                binaryData = mem.ToArray();
            }

            using (MemoryStream mem = new MemoryStream())
            {
                datacontractserializer.Serialize(obj, mem);
                dataContractData = mem.ToArray();
            }
#endif

#if NETFULL
            using (MemoryStream mem = new MemoryStream())
            {
                soapserializer.Serialize(obj, mem);
                soapData = mem.ToArray();
            }
#endif

            var netserializer = SerializerFactory.Get("NET");
            using (MemoryStream mem = new MemoryStream())
            {
                netserializer.Serialize(obj, mem);
                netData = mem.ToArray();
            }

            var jsonnetSerializedText  = jsonnetserializer.SerializeToString(obj);
            var textjsonSerializedText = textjsonserializer.SerializeToString(obj);
            var xmlSerializedText      = xmlserializer.SerializeToString(obj);
            using (MemoryStream mem = new MemoryStream())
            {
                protobufserializer.Serialize(obj, mem);
                protobufData = mem.ToArray();
            }

            var keys = serializer.Keys.ToList();

#if NETFULL || NETCOREAPP3_1
            serializer["Jil"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Jil"].Score = Helper.AverageRuntime(() =>
                {
                    jilserializer.DeserializeFromString(jilSerializedText, objType);
                }, runs);
            };
            serializer["Binary"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Binary"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream(binaryData))
                    {
                        binaryserializer.Deserialize(mem, objType);
                    }
                }, runs);
            };

            serializer["DataContract"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["DataContract"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream(dataContractData))
                    {
                        datacontractserializer.Deserialize(mem, objType);
                    }
                }, runs);
            };
#endif

#if NETFULL
            serializer["Soap"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Soap"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream(soapData))
                    {
                        soapserializer.Deserialize(mem, objType);
                    }
                }, runs);
            };
#endif

            serializer["NET"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["NET"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream(netData))
                    {
                        netserializer.Deserialize(mem, objType);
                    }
                }, runs);
            };

            serializer["Json"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Json"].Score = Helper.AverageRuntime(() =>
                {
                    jsonnetserializer.DeserializeFromString(jsonnetSerializedText, objType);
                }, runs);
            };

            serializer["TextJson"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["TextJson"].Score = Helper.AverageRuntime(() =>
                {
                    textjsonserializer.DeserializeFromString(textjsonSerializedText, objType);
                }, runs);
            };

            serializer["Xml"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Xml"].Score = Helper.AverageRuntime(() =>
                {
                    xmlserializer.DeserializeFromString(xmlSerializedText, objType);
                }, runs);
            };

            serializer["Protobuf"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Protobuf"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream(protobufData))
                    {
                        protobufserializer.Deserialize(mem, objType);
                    }
                }, runs);
            };

            keys.ForEach(k =>
            {
                serializer[k].Act();
            });
        }
Exemple #21
0
 public void Can_xml_deep_clone()
 {
     Test_Deep_Clone(SerializerFactory.Get("xml"));
 }
Exemple #22
0
 public void Can_ProtoBuf_deep_clone()
 {
     Test_Deep_Clone(SerializerFactory.Get("ProtoBuf"));
 }
Exemple #23
0
 public void Can_jsonNet_deep_clone()
 {
     Test_Deep_Clone(SerializerFactory.Get("jsonNet"));
 }
Exemple #24
0
 public void Can_dc_deep_clone()
 {
     Test_Deep_Clone(SerializerFactory.Get("dc"));
 }
Exemple #25
0
 public EmployeeImporter(string apiFormat)
 {
     _serializer     = SerializerFactory.Get(apiFormat);
     _commonImporter = new CommonImporter(RedmineResources.Employees, apiFormat);
 }
 public TimeRecordImporter(string apiFormat)
 {
     _serializer     = SerializerFactory.Get(apiFormat);
     _commonImporter = new CommonImporter(RedmineResources.TimeRecords, apiFormat);
 }
Exemple #27
0
        private void CompareSerializers <T>(T obj, int runs)
        {
            //warm-up

#if NETFULL || NETCOREAPP3_1
            jilserializer.SerializeToString(obj);
            using (MemoryStream mem = new MemoryStream())
            {
                binaryserializer.Serialize(obj, mem);
            }

            using (MemoryStream mem = new MemoryStream())
            {
                datacontractserializer.Serialize(obj, mem);
            }
#endif

#if NETFULL
            using (MemoryStream mem = new MemoryStream())
            {
                soapserializer.Serialize(obj, mem);
            }
#endif

            var netserializer = SerializerFactory.Get("NET");
            using (MemoryStream mem = new MemoryStream())
            {
                netserializer.Serialize(obj, mem);
            }

            jsonnetserializer.SerializeToString(obj);
            textjsonserializer.SerializeToString(obj);

            using (MemoryStream mem = new MemoryStream())
            {
                protobufserializer.Serialize(obj, mem);
            }


            xmlserializer.SerializeToString(obj);

            var keys = serializer.Keys.ToList();

#if NETFULL || NETCOREAPP3_1
            serializer["Jil"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Jil"].Score = Helper.AverageRuntime(() =>
                {
                    jilserializer.SerializeToString(obj);
                }, runs);
            };
            serializer["Binary"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Binary"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        binaryserializer.Serialize(obj, mem);
                    }
                }, runs);
            };

            serializer["DataContract"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["DataContract"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        datacontractserializer.Serialize(obj, mem);
                    }
                }, runs);
            };
#endif

#if NETFULL
            serializer["Soap"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Soap"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        soapserializer.Serialize(obj, mem);
                    }
                }, runs);
            };
#endif

            serializer["NET"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["NET"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        netserializer.Serialize(obj, mem);
                    }
                }, runs);
            };

            serializer["Json"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Json"].Score = Helper.AverageRuntime(() =>
                {
                    jsonnetserializer.SerializeToString(obj);
                }, runs);
            };

            serializer["TextJson"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["TextJson"].Score = Helper.AverageRuntime(() =>
                {
                    textjsonserializer.SerializeToString(obj);
                }, runs);
            };

            serializer["Xml"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Xml"].Score = Helper.AverageRuntime(() =>
                {
                    xmlserializer.SerializeToString(obj);
                }, runs);
            };

            serializer["Protobuf"].Act = () =>
            {
                GC.Collect(2, GCCollectionMode.Forced, blocking: true);
                serializer["Protobuf"].Score = Helper.AverageRuntime(() =>
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        protobufserializer.Serialize(obj, mem);
                    }
                }, runs);
            };

            keys.ForEach(k =>
            {
                serializer[k].Act();
            });
        }
 public IssueStatusImporter(string apiFormat)
 {
     _serializer     = SerializerFactory.Get(apiFormat);
     _commonImporter = new CommonImporter(RedmineResources.IssueStatuses, apiFormat);
 }
Exemple #29
0
        private String Serialize <T>(T instance)
        {
            var serializer = SerializerFactory.Get <T>(this.Options);

            return(serializer.Serialize(instance));
        }