Ejemplo n.º 1
0
        private void serializePreferredCustomer_Click(object sender, EventArgs e)
        {
            var customer = new PreferredCustomer()
            {
                FirstName = "Sergio",
                LastName  = "Garcia",
                BirthDate = new DateTime(1984, 9, 13),
                Seller    = "Jack"
            };

            var serializer = new DataContractSerializer(typeof(Customer), new [] { typeof(PreferredCustomer) });

            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, customer);
                objectData.Text = Encoding.UTF8.GetString(stream.ToArray());
            }
        }
Ejemplo n.º 2
0
        private void serializePreferredCustomer_Click(object sender, EventArgs e)
        {
            var customer = new PreferredCustomer()
                               {
                                   FirstName = "Sergio",
                                   LastName = "Garcia",
                                   BirthDate = new DateTime(1984, 9, 13),
                                   Seller = "Jack"
                               };

            var serializer = new DataContractSerializer(typeof(Customer), new [] {typeof(PreferredCustomer)});

            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, customer);
                objectData.Text = Encoding.UTF8.GetString(stream.ToArray());
            }
        }