示例#1
0
        private static void DataContractSerizalizerHelperTest()
        {
            Customer customer = new Customer
            {
                Id          = 1,
                FirstName   = "John",
                LastName    = "Smith",
                Salary      = 1000,
                DateOfBirth = DateTime.Parse("1980-01-30"),
                IsRemoved   = true
            };

            string xml = DataContractSerizalizerHelper.Serialize(customer);

            Console.WriteLine(xml);

            Customer deserializedCustomer = DataContractSerizalizerHelper.Deserialize <Customer>(xml);

            if (object.ReferenceEquals(customer, deserializedCustomer))
            {
                Console.WriteLine("the same");
            }
            else
            {
                Console.WriteLine("another");
            }
        }
示例#2
0
 public static T Deserialize <T>(this string xml)
     where T : new()
 {
     return(DataContractSerizalizerHelper.Deserialize <T>(xml));
 }
示例#3
0
 public static string Serialize <T>(this T o)
 {
     return(DataContractSerizalizerHelper.Serialize <T>(o));
 }