Пример #1
0
        public void TestMethod1()
        {
            SerializerEngine engine = new SerializerEngine();
            MemoryStream stream = new MemoryStream();

            TestClass root = new TestClass();
            root.ListProperty = new List<string>();
            root.DictionaryProperty = new Dictionary<string, int>();
            root.ArrayProperty = new int[10];
            for (int i = 0; i < 10; i++)
                root.ArrayProperty[i] = 1000 + i;

            root.NullableProperty = DateTime.Now;
            root.PrimitiveProperty = 123;
            root.ReferenceProperty = new ClassA();
            root.ReferenceProperty.B = new ClassB();
            root.ReferenceProperty.B.A = root.ReferenceProperty;

            root.DictionaryProperty.Add("a", 1);
            root.DictionaryProperty.Add("b", 2);
            root.DictionaryProperty.Add("c", 3);

            engine.Serialize(stream, root);

            stream.Position = 0;
            StreamReader sr = new StreamReader(stream);
            string result = sr.ReadToEnd();


        }
Пример #2
0
        public void TestMethod1()
        {
            SerializerEngine engine = new SerializerEngine();
            MemoryStream     stream = new MemoryStream();

            TestClass root = new TestClass();

            root.ListProperty       = new List <string>();
            root.DictionaryProperty = new Dictionary <string, int>();
            root.ArrayProperty      = new int[10];
            for (int i = 0; i < 10; i++)
            {
                root.ArrayProperty[i] = 1000 + i;
            }

            root.NullableProperty      = DateTime.Now;
            root.PrimitiveProperty     = 123;
            root.ReferenceProperty     = new ClassA();
            root.ReferenceProperty.B   = new ClassB();
            root.ReferenceProperty.B.A = root.ReferenceProperty;

            root.DictionaryProperty.Add("a", 1);
            root.DictionaryProperty.Add("b", 2);
            root.DictionaryProperty.Add("c", 3);

            engine.Serialize(stream, root);

            stream.Position = 0;
            StreamReader sr     = new StreamReader(stream);
            string       result = sr.ReadToEnd();
        }
Пример #3
0
        private void SaveProject()
        {
            //var fs = new FileStream("c:\\productobjectsoapformatted.Data", FileMode.Create);
            //var sf = new BinaryFormatter
            //         {
            //             AssemblyFormat = FormatterAssemblyStyle.Simple,
            //             FilterLevel = TypeFilterLevel.Full,
            //             TypeFormat = FormatterTypeStyle.TypesAlways
            //         };

            //sf.Serialize(fs, root);
            //fs.Close();
            var se = new SerializerEngine();

            using (var fs = new FileStream(@"c:\labb.txt", FileMode.Create))
            {
                se.Serialize(fs, root);
                fs.Flush();
            }
        }
Пример #4
0
 public void Serialize(Stream output, object graph)
 {
     SerializerEngine context = new SerializerEngine();
     context.Serialize(output, graph);
 }
Пример #5
0
        public void Serialize(Stream output, object graph)
        {
            SerializerEngine context = new SerializerEngine();

            context.Serialize(output, graph);
        }