public XmlOrder(Guid id, DateTime date, XmlProduct product, int quantity) { this._orderID = id; this._orderDate = date; this._product = product; this._quantity = quantity; }
private static void XmlToXmlSerialization() { var product = new XmlProduct(Guid.NewGuid(), "productTestName", "china", 10.25); var order = new XmlOrder(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 XmlSerializer(typeof(XmlOrder)); using (var writer = XmlDictionaryWriter.CreateTextWriter(stream)) { serializationTool.Serialize(writer, order); } Process.Start(fullFileName); } }