Exemplo n.º 1
0
        private MyClass CreateModel()
        {
            var c = new MyClass
            {
                MyId = 123,
                MyString = "John",
                MyGuid = Guid.NewGuid(),
                MyDateTime = DateTime.Now,
                MyProperty = "SerializeTHIS",
                MyIgnore = "IgnoreTHIS",
                MyIntNullable = 999,
                MyStringList = new List<string>() { "String-1", "String-2" },
                MyWriteOnly = "write-only",
                MyInternalProperty = "internal-field",
                MyNameValueCollection = new NameValueCollection(),
                MyDict = new Dictionary<int, string>() { { 1, "Row1" }, { 2, "Row2" } },
                MyStringArray = new string[] { "One", "Two" },
                MyEnumProp = MyEnum.Second,
                MyChar = 'Y',
                MyUri = new Uri("http://www.numeria.com.br"),
                MyByte = 255,
                MyDecimal = 19.9m,
                MyDecimalNullable = 25.5m,

                MyInterface = new MyImpl { Name = "John" },
                MyListInterface = new List<IMyInterface>() { new MyImpl { Name = "John" } },
                MyIListInterface = new List<IMyInterface>() { new MyImpl { Name = "John" } },

                MyObjectString = "MyString",
                MyObjectInt = 123,
                MyObjectImpl = new MyImpl { Name = "John" },
                MyObjectList = new List<object>() { 1, "ola", new MyImpl { Name = "John" }, new Uri("http://www.cnn.com") }
            };

            c.MyNameValueCollection["key-1"] = "value-1";
            c.MyNameValueCollection["KeyNumber2"] = "value-2";

            return c;
        }
Exemplo n.º 2
0
        private MyClass CreateModel()
        {
            var c = new MyClass
            {
                MyId       = 123,
                MyString   = "John",
                MyGuid     = Guid.NewGuid(),
                MyDateTime = DateTime.Now,
                //MyProperty = "SerializeTHIS",
                MyIgnore      = "IgnoreTHIS",
                MyIntNullable = 999,
                MyStringList  = new List <string>()
                {
                    "String-1", "String-2"
                },
                MyWriteOnly = "write-only",
                //MyInternalProperty = "internal-field",
                MyDict = new Dictionary <int, string>()
                {
                    { 1, "Row1" }, { 2, "Row2" }
                },
                MyDictEnum = new Dictionary <StringComparison, string>()
                {
                    { StringComparison.Ordinal, "ordinal" }
                },
                MyStringArray          = new string[] { "One", "Two" },
                MyStringEnumerable     = new string[] { "One", "Two" },
                CustomStringEnumerable = new CustomStringEnumerable(new string[] { "One", "Two" }),
                MyEnumProp             = MyEnum.Second,
                MyChar     = 'Y',
                MyUri      = new Uri("http://www.numeria.com.br"),
                MyByte     = 255,
                MySByte    = -99,
                MyField    = "Field test",
                MyTimespan = TimeSpan.FromDays(1),
                // MyKeyValuePair = new KeyValuePair<string, int>("my-key", 123),
                MyDecimal         = 19.9m,
                MyDecimalNullable = 25.5m,

                MyInterface = new MyImpl {
                    Name = "John"
                },
                MyListInterface = new List <IMyInterface>()
                {
                    new MyImpl {
                        Name = "John"
                    }
                },
                MyIListInterface = new List <IMyInterface>()
                {
                    new MyImpl {
                        Name = "John"
                    }
                },

                MyObjectString = "MyString",
                MyObjectInt    = 123,
                MyObjectImpl   = new MyImpl {
                    Name = "John"
                },
                MyObjectList = new List <object>()
                {
                    1, "ola", new MyImpl {
                        Name = "John"
                    }, new Uri("http://www.cnn.com")
                }
            };

            return(c);
        }
Exemplo n.º 3
0
        private MyClass CreateModel()
        {
            var c = new MyClass
            {
                MyId          = 123,
                MyString      = "John",
                MyGuid        = Guid.NewGuid(),
                MyDateTime    = DateTime.Now,
                MyProperty    = "SerializeTHIS",
                MyIgnore      = "IgnoreTHIS",
                MyIntNullable = 999,
                MyStringList  = new List <string>()
                {
                    "String-1", "String-2"
                },
                MyWriteOnly           = "write-only",
                MyInternalProperty    = "internal-field",
                MyNameValueCollection = new NameValueCollection(),
                MyDict = new Dictionary <int, string>()
                {
                    { 1, "Row1" }, { 2, "Row2" }
                },
                MyStringArray     = new string[] { "One", "Two" },
                MyEnumProp        = MyEnum.Second,
                MyChar            = 'Y',
                MyUri             = new Uri("http://www.numeria.com.br"),
                MyByte            = 255,
                MyDecimal         = 19.9m,
                MyDecimalNullable = 25.5m,

                MyInterface = new MyImpl {
                    Name = "John"
                },
                MyListInterface = new List <IMyInterface>()
                {
                    new MyImpl {
                        Name = "John"
                    }
                },
                MyIListInterface = new List <IMyInterface>()
                {
                    new MyImpl {
                        Name = "John"
                    }
                },

                MyObjectString = "MyString",
                MyObjectInt    = 123,
                MyObjectImpl   = new MyImpl {
                    Name = "John"
                },
                MyObjectList = new List <object>()
                {
                    1, "ola", new MyImpl {
                        Name = "John"
                    }, new Uri("http://www.cnn.com")
                }
            };

            c.MyNameValueCollection["key-1"]      = "value-1";
            c.MyNameValueCollection["KeyNumber2"] = "value-2";

            return(c);
        }