Ejemplo n.º 1
0
        static void DeserializeToNewVersion(string path)
        {
            Console.WriteLine
                ("Deserializing to new version, extension data intact");
            FileStream          fs     = new FileStream(path, FileMode.Open);
            XmlDictionaryReader reader =
                XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());
            NetDataContractSerializer ser =
                new NetDataContractSerializer();
            PurchaseOrderV2 newOrder =
                (PurchaseOrderV2)ser.ReadObject(reader, false);

            Console.WriteLine("Original OrderID: {0}", newOrder.PurchaseOrderId);
            Console.WriteLine("New Order Date: {0}",
                              newOrder.PurchaseDate.ToLongDateString());
            fs.Close();
        }
Ejemplo n.º 2
0
        static void SerializeNewVersion(string path)
        {
            Console.WriteLine("Serializing new version of a contract.");
            FileStream fs = new FileStream(path,
                                           FileMode.Create);
            NetDataContractSerializer ser =
                new NetDataContractSerializer();
            PurchaseOrderV2 PO_V2 = new PurchaseOrderV2();

            PO_V2.PurchaseDate    = DateTime.Now;
            PO_V2.PurchaseOrderId = 1234;
            ser.WriteObject(fs, PO_V2);
            fs.Close();
            Console.WriteLine("Order Date: {0}",
                              PO_V2.PurchaseDate.ToLongDateString());
            Console.WriteLine("Order ID:{0}", PO_V2.PurchaseOrderId);
        }