コード例 #1
0
 public DataContractOrder(Guid id, DateTime date, DataContractProduct product, int quantity)
 {
     this._orderID   = id;
     this._orderDate = date;
     this._product   = product;
     this._quantity  = quantity;
 }
コード例 #2
0
 public DataContractOrder(Guid id, DateTime date, DataContractProduct product, int quantity)
 {
     this._orderID = id;
     this._orderDate = date;
     this._product = product;
     this._quantity = quantity;
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Kelvin-Lei/WCFService_Demo
 static void SerializeViaDataContractSerializer()
 {
     DataContractProduct product = new DataContractProduct(Guid.NewGuid(), "Dell PC", "Xiamen FuJian", 4500);
     DataContractOrder order = new DataContractOrder(Guid.NewGuid(), DateTime.Today, product, 300);
     string fileName = _basePath + "Order.DataContractSerializer.xml";
     using (FileStream fs = new FileStream(fileName, FileMode.Create))
     {
         DataContractSerializer serializer = new DataContractSerializer(typeof(DataContractOrder));
         using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(fs))
         {
             serializer.WriteObject(writer, order);
         }
     }
     Process.Start(fileName);
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: Kelvin-Lei/WCFService_Demo
        static void SerializeViaDataContractSerializer()
        {
            DataContractProduct product = new DataContractProduct(Guid.NewGuid(), "Dell PC", "Xiamen FuJian", 4500);
            DataContractOrder   order   = new DataContractOrder(Guid.NewGuid(), DateTime.Today, product, 300);
            string fileName             = _basePath + "Order.DataContractSerializer.xml";

            using (FileStream fs = new FileStream(fileName, FileMode.Create))
            {
                DataContractSerializer serializer = new DataContractSerializer(typeof(DataContractOrder));
                using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(fs))
                {
                    serializer.WriteObject(writer, order);
                }
            }
            Process.Start(fileName);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: 0811112150/HappyDayHistory
        private static void DataContractToXmlSerialization()
        {
            var product = new DataContractProduct(Guid.NewGuid(), "productTestName", "china", 10.25);
            var order = new DataContractOrder(Guid.NewGuid(), DateTime.Now, product, 10);

            var baseDir = AppDomain.CurrentDomain.BaseDirectory;
            var fileName = "../xml.xml";
            var fullFileName = Path.Combine(baseDir, fileName);

            using (var stream = new FileStream(fullFileName, FileMode.Create)) {
                var serializationTool = new DataContractSerializer(typeof(XmlOrder));
                using (var writer = XmlDictionaryWriter.CreateTextWriter(stream)) {
                    serializationTool.WriteObject(writer, order);
                }
                Process.Start(fullFileName);
            }
        }