Default XML Serializer
Наследование: ISerializer
Пример #1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public RestRequest()
 {
     Parameters = new List<Parameter>();
     Files = new List<FileParameter>();
     XmlSerializer = new XmlSerializer();
     JsonSerializer = new JsonSerializer();
 }
Пример #2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public RestRequest()
        {
            Parameters = new List<Parameter>();
            Files = new List<FileParameter>();
            XmlSerializer = new XmlSerializer();
            JsonSerializer = new JsonSerializer();

            OnBeforeDeserialization = r => { };
        }
Пример #3
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public RestRequest()
        {
            Parameters = new List<Parameter>();
            Files = new List<FileParameter>();
            XmlSerializer = new XmlSerializer();
            JsonSerializer = new JsonSerializer();

            OnBeforeDeserialization = r => { };
            #if FRAMEWORK
            AttemptPostFilesWithoutBuffering = false;
            #endif
        }
Пример #4
0
        public void Can_serialize_simple_POCO_With_Attribute_Options_Defined()
        {
            var poco = new WackyPerson {
                Name = "Foo",
                Age = 50,
                Price = 19.95m,
                StartDate = new DateTime(2009, 12, 18, 10, 2, 23)
            };

            var xml = new XmlSerializer();
            var doc = xml.Serialize(poco);
            var expected = GetSimplePocoXDocWackyNames();

            Assert.Equal(expected.ToString(), doc.ToString());
        }
Пример #5
0
        public void Can_serialize_simple_POCO_With_DateFormat_Specified()
        {
            var poco = new Person {
                Name = "Foo",
                Age = 50,
                Price = 19.95m,
                StartDate = new DateTime(2009, 12, 18, 10, 2, 23)
            };

            var xml = new XmlSerializer();
            xml.DateFormat = DateFormat.Iso8601;
            var doc = xml.Serialize(poco);
            var expected = GetSimplePocoXDocWithIsoDate();

            Assert.Equal(expected.ToString(), doc.ToString());
        }
Пример #6
0
        public void Can_serialize_simple_POCO()
        {
            var poco = new Person {
                Name = "Foo",
                Age = 50,
                Price = 19.95m,
                StartDate = new DateTime(2009, 12, 18, 10, 2, 23),
                Items = new List<Item> {
                    new Item { Name = "One", Value = 1 },
                    new Item { Name = "Two", Value = 2 },
                    new Item { Name = "Three", Value = 3 }
                }
            };

            var xml = new XmlSerializer();
            var doc = xml.Serialize(poco);
            var expected = GetSimplePocoXDoc();

            Assert.Equal(expected.ToString(), doc.ToString());
        }
Пример #7
0
        public void Can_serialize_simple_POCO_With_Different_Root_Element()
        {
            var poco = new Person {
                Name = "Foo",
                Age = 50,
                Price = 19.95m,
                StartDate = new DateTime(2009, 12, 18, 10, 2, 23)
            };

            var xml = new XmlSerializer();
            xml.RootElement = "Result";
            var doc = xml.Serialize(poco);
            var expected = GetSimplePocoXDocWithRoot();

            Assert.Equal(expected.ToString(), doc.ToString());
        }
Пример #8
0
        public void Serializes_Properties_In_Specified_Order()
        {
            var ordered = new OrderedProperties();
            ordered.Name = "Name";
            ordered.Age = 99;
            ordered.StartDate = new DateTime(2010, 1, 1);

            var xml = new XmlSerializer();
            var doc = xml.Serialize(ordered);

            var expected = GetSortedPropsXDoc();

            Assert.Equal(expected.ToString(), doc.ToString());
        }