using System;
namespace ObjectModelGenerator
{
public class SimpleExampleUsage
{
///
/// This example creates a new document, fills it up a bit and then saves it to disk.
///
public static void CreateNew()
{
// Create a new DOM root elemnt.
MyDataSetElement newDocumentRootElement = new MyDataSetElement();
// Fill it up with new data.
MyDataSetElement.customersElement customer1 = new MyDataSetElement.customersElement();
customer1.CustomerID = 14m;
customer1.CompanyName = "Give Us All Your Money Inc.";
customer1.Phone = "555-1234";
newDocumentRootElement.customerss.Add(customer1);
MyDataSetElement.customersElement customer2 = new MyDataSetElement.customersElement();
// This means that the customer id will not get serialized, due to it being null.
customer1.SetCustomerIDNull();
customer1.CompanyName = "Rotten To The Corp.";
customer1.Phone = "555-9872";
newDocumentRootElement.customerss.Add(customer2);
// Create an xml document from the dom.
MyDataSetDocument actualXmlDocument = MyDataSetDocument.FromDOM(newDocumentRootElement);
// Save the xml document to file.
actualXmlDocument.Save("customers.xml");
}
///
/// This example loads the document we have created.
///
public static void LoadFromFile()
{
// Create a blank xml document object.
MyDataSetDocument actualXmlDocument = new MyDataSetDocument();
// Load the data from the xml file. Note: This validates the XML. Prone to exceptions.
actualXmlDocument.Load("customers.xml");
// Create the DOM from the xml.
MyDataSetElement rootElement = actualXmlDocument.CreateDOM();
}
}
}