//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version: 1.1.4322.573 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ // The following code was generated automatically by use of the Object Model Generator. // If you feel this tool has helped you in any way or there are bugs to notify me of, // please let me know at ovanklot@gmx.net or http://weblogs.asp.net/OKloeten/. // // Omer van Kloeten namespace ObjectModelGenerator { // TODO: Complete Summary tag documentation. /// Represents the MyDataSet element. public class MyDataSetElement : object, IXmlElement, System.ICloneable { /// This field holds the collection of objects. private CustomersCollection m_Customerss; /// Represents the referencing name for the inner text of the element. public const string ElementTextName = "#text"; /// Represents the inner text of the element. private string m_Text; /// Represents the referencing name for the element. public const string ElementName = "MyDataSet"; /// This is the default constructor. public MyDataSetElement() { this.m_Customerss = this.CreateCustomersCollection(); } /// This constructor is used to deserialize the element from XML DOM. protected internal MyDataSetElement(System.Xml.XmlElement element) { if ((element.Name != ElementName)) { throw new System.ApplicationException("Invalid element initialization."); } this.m_Customerss = new CustomersCollection(element, this); if ((element.Attributes[ElementTextName] != null)) { this.m_Text = element.Attributes[ElementTextName].Value; } } /// Gets the collection of objects. public CustomersCollection Customerss { get { return this.m_Customerss; } } // TODO: Complete Summary tag documentation. /// Represents the inner text of the element. public string Text { get { return this.m_Text; } set { if ((this.m_Text != value)) { this.m_Text = value; this.OnTextChanged(System.EventArgs.Empty); } } } /// Raised when the element's inner text is changed. public event System.EventHandler TextChanged; protected virtual CustomersCollection CreateCustomersCollection() { return new CustomersCollection(this); } /// Equality operator override. /// This does not support checking for equality for untyped attributes. public static bool operator ==(MyDataSetElement left, MyDataSetElement right) { return (((((object)(left)) == null) && (((object)(right)) == null)) || ((((object)(left)) != null) && (left.Equals(right) == true))); } /// Equality operator override. /// This does not support checking for equality for untyped attributes. public static bool operator !=(MyDataSetElement left, MyDataSetElement right) { return ((left == right) == false); } /// Raises the event. protected void OnTextChanged(System.EventArgs e) { if ((this.TextChanged != null)) { this.TextChanged(this, e); } } /// Serves as a hash function for the type, suitable for use in hashing algorithms and data structures like a hash table. public override int GetHashCode() { return base.GetHashCode(); } /// Compares two instances of an element of type . /// This does not support checking for equality for untyped attributes. public override bool Equals(object obj) { return ((((obj != null) && (obj.GetType() == typeof(MyDataSetElement))) && (this.m_Customerss == ((MyDataSetElement)(obj)).m_Customerss)) && (this.m_Text == ((MyDataSetElement)(obj)).m_Text)); } /// This method is used to serialize the element to XML DOM. System.Xml.XmlElement IXmlElement.GetXml(System.Xml.XmlDocument document) { System.Xml.XmlElement element = document.CreateElement(ElementName); System.Xml.XmlElement[] customerss = ((IXmlElementCollection)(this.Customerss)).GetXml(document); for (int index = 0; (index < customerss.Length); index = (index + 1)) { element.AppendChild(customerss[index]); } if (((this.m_Text != null) && (this.m_Text != string.Empty))) { element.AppendChild(document.CreateTextNode(this.m_Text)); } return element; } /// This method is used to to clone the element. public object Clone() { MyDataSetElement clone = new MyDataSetElement(); clone.m_Customerss = ((CustomersCollection)(this.m_Customerss.Clone())); clone.m_Customerss.SetParentMyDataSetElement(clone); return clone; } // TODO: Complete Summary tag documentation. /// Represents the customers element. public class CustomersElement : object, IXmlElement, System.ICloneable { /// This field is used to create the CustomerID attribute/simple element. private System.Decimal m_CustomerID; /// Represents the referencing name for CustomerID. public const string CustomerIDName = "CustomerID"; /// Holds the null status for the value type of the CustomerID attribute/simple element. private bool m_IsCustomerIDNull = true; /// This field is used to create the CompanyName attribute/simple element. private string m_CompanyName; /// Represents the referencing name for CompanyName. public const string CompanyNameName = "CompanyName"; /// This field is used to create the Phone attribute/simple element. private string m_Phone; /// Represents the referencing name for Phone. public const string PhoneName = "Phone"; /// Represents the referencing name for the inner text of the element. public const string ElementTextName = "#text"; /// Represents the inner text of the element. private string m_Text; /// Represents the referencing name for the element. public const string ElementName = "customers"; /// Represents the parent for this element. private MyDataSetElement m_ParentMyDataSetElement; /// This is the default constructor. public CustomersElement() { } /// This constructor is used to deserialize the element from XML DOM. protected internal CustomersElement(System.Xml.XmlElement element) { if ((element.Name != ElementName)) { throw new System.ApplicationException("Invalid element initialization."); } if ((element[ElementName] != null)) { this.CustomerID = ((System.Decimal)(System.Convert.ChangeType(element[ElementName].Value, typeof(System.Decimal)))); } else { this.SetCustomerIDNull(); } if ((element[ElementName] != null)) { this.CompanyName = ((string)(System.Convert.ChangeType(element[ElementName].Value, typeof(string)))); } if ((element[ElementName] != null)) { this.Phone = ((string)(System.Convert.ChangeType(element[ElementName].Value, typeof(string)))); } if ((element.Attributes[ElementTextName] != null)) { this.m_Text = element.Attributes[ElementTextName].Value; } } // TODO: Complete Summary tag documentation. /// Represents the CustomerID attribute/simple element for this element. public System.Decimal CustomerID { get { return this.m_CustomerID; } set { if ((this.m_CustomerID != value)) { this.m_CustomerID = value; this.OnCustomerIDChanged(System.EventArgs.Empty); } // After setting the value, it is no longer null. this.m_IsCustomerIDNull = false; } } /// Gets whether the value type of the CustomerID attribute/simple element is null. public bool IsCustomerIDNull { get { return this.m_IsCustomerIDNull; } } // TODO: Complete Summary tag documentation. /// Represents the CompanyName attribute/simple element for this element. public string CompanyName { get { return this.m_CompanyName; } set { if ((this.m_CompanyName != value)) { this.m_CompanyName = value; this.OnCompanyNameChanged(System.EventArgs.Empty); } } } // TODO: Complete Summary tag documentation. /// Represents the Phone attribute/simple element for this element. public string Phone { get { return this.m_Phone; } set { if ((this.m_Phone != value)) { this.m_Phone = value; this.OnPhoneChanged(System.EventArgs.Empty); } } } // TODO: Complete Summary tag documentation. /// Represents the inner text of the element. public string Text { get { return this.m_Text; } set { if ((this.m_Text != value)) { this.m_Text = value; this.OnTextChanged(System.EventArgs.Empty); } } } /// Gets the parent for this element. public MyDataSetElement ParentMyDataSetElement { get { return this.m_ParentMyDataSetElement; } } /// Raised when the property is changed. public event System.EventHandler CustomerIDChanged; /// Raised when the property is changed. public event System.EventHandler CompanyNameChanged; /// Raised when the property is changed. public event System.EventHandler PhoneChanged; /// Raised when the element's inner text is changed. public event System.EventHandler TextChanged; /// Raises the event. protected virtual void OnCustomerIDChanged(System.EventArgs e) { if ((this.CustomerIDChanged != null)) { this.CustomerIDChanged(this, e); } } /// Sets the value type of the CustomerID attribute/simple element to null. public void SetCustomerIDNull() { this.m_IsCustomerIDNull = true; } /// Raises the event. protected virtual void OnCompanyNameChanged(System.EventArgs e) { if ((this.CompanyNameChanged != null)) { this.CompanyNameChanged(this, e); } } /// Raises the event. protected virtual void OnPhoneChanged(System.EventArgs e) { if ((this.PhoneChanged != null)) { this.PhoneChanged(this, e); } } /// Equality operator override. /// This does not support checking for equality for untyped attributes. public static bool operator ==(CustomersElement left, CustomersElement right) { return (((((object)(left)) == null) && (((object)(right)) == null)) || ((((object)(left)) != null) && (left.Equals(right) == true))); } /// Equality operator override. /// This does not support checking for equality for untyped attributes. public static bool operator !=(CustomersElement left, CustomersElement right) { return ((left == right) == false); } /// Raises the event. protected void OnTextChanged(System.EventArgs e) { if ((this.TextChanged != null)) { this.TextChanged(this, e); } } /// Serves as a hash function for the type, suitable for use in hashing algorithms and data structures like a hash table. public override int GetHashCode() { return base.GetHashCode(); } /// Compares two instances of an element of type . /// This does not support checking for equality for untyped attributes. public override bool Equals(object obj) { return ((((obj != null) && (obj.GetType() == typeof(CustomersElement))) && ((((this.m_CustomerID == ((CustomersElement)(obj)).m_CustomerID) && (this.IsCustomerIDNull == ((CustomersElement)(obj)).IsCustomerIDNull)) && (this.m_CompanyName == ((CustomersElement)(obj)).m_CompanyName)) && (this.m_Phone == ((CustomersElement)(obj)).m_Phone))) && (this.m_Text == ((CustomersElement)(obj)).m_Text)); } /// This method is used to serialize the element to XML DOM. System.Xml.XmlElement IXmlElement.GetXml(System.Xml.XmlDocument document) { System.Xml.XmlElement element = document.CreateElement(ElementName); if ((this.IsCustomerIDNull == false)) { System.Xml.XmlElement elmCustomerID = document.CreateElement(ElementName); elmCustomerID.Value = this.CustomerID.ToString(); element.AppendChild(elmCustomerID); } if ((this.CompanyName != null)) { System.Xml.XmlElement elmCompanyName = document.CreateElement(ElementName); elmCompanyName.Value = this.CompanyName.ToString(); element.AppendChild(elmCompanyName); } if ((this.Phone != null)) { System.Xml.XmlElement elmPhone = document.CreateElement(ElementName); elmPhone.Value = this.Phone.ToString(); element.AppendChild(elmPhone); } if (((this.m_Text != null) && (this.m_Text != string.Empty))) { element.AppendChild(document.CreateTextNode(this.m_Text)); } return element; } /// This method is used to to clone the element. public object Clone() { CustomersElement clone = new CustomersElement(); if ((this.IsCustomerIDNull == false)) { clone.CustomerID = this.CustomerID; } else { clone.SetCustomerIDNull(); } clone.m_CompanyName = this.m_CompanyName; clone.m_Phone = this.m_Phone; return clone; } /// Sets a value for the parent for this element. protected internal void SetParentMyDataSetElement(MyDataSetElement value) { this.m_ParentMyDataSetElement = value; } } /// This is a typed collection for the customersCollection () element. public class CustomersCollection : System.Collections.CollectionBase, IXmlElementCollection, System.ICloneable { private const int MinAmount = 1; /// The parent element for this collection. private MyDataSetElement m_Parent; /// Default internal constructor. protected internal CustomersCollection(MyDataSetElement parent) { this.m_Parent = parent; } /// This constructor is used to deserialize the element collection from XML DOM. protected internal CustomersCollection(System.Xml.XmlElement parentElement, MyDataSetElement parent) { this.m_Parent = parent; for (int index = 0; (index < parentElement.ChildNodes.Count); index = (index + 1)) { if (((parentElement.ChildNodes[index].GetType() == typeof(System.Xml.XmlElement)) && (parentElement.ChildNodes[index].Name == CustomersElement.ElementName))) { base.InnerList.Add(new CustomersElement(((System.Xml.XmlElement)(parentElement.ChildNodes[index])))); } } } /// Gets or sets the at the specific index. public CustomersElement this[int index] { get { return ((CustomersElement)(base.InnerList[index])); } set { if ((this[index] != value)) { base.InnerList[index] = value; this.OnCollectionChanged(System.EventArgs.Empty); } } } /// This event is invoked whenever the collection has items added to it or removed from it. public event System.EventHandler CollectionChanged; /// Adds a to the end of the collection. public int Add(CustomersElement value) { value.SetParentMyDataSetElement(this.m_Parent); int location = base.InnerList.Add(value); this.OnCollectionChanged(System.EventArgs.Empty); return location; } /// Determines whether the object is in the collection. public bool Contains(CustomersElement value) { return base.InnerList.Contains(value); } /// Returns the zero-based index of the first occurrence of the object in the collection. public int IndexOf(CustomersElement value) { return base.InnerList.IndexOf(value); } /// Inserts an object of type into the collection at the specified index. public void Insert(int index, CustomersElement value) { value.SetParentMyDataSetElement(this.m_Parent); base.InnerList.Insert(index, value); this.OnCollectionChanged(System.EventArgs.Empty); } /// Removes the first occurrence of a specific object from the collection. public void Remove(CustomersElement value) { // Check to see if we have reached the minimum amount. if ((base.InnerList.Count == MinAmount)) { throw new System.ApplicationException("Minimum amount of items reached."); } value.SetParentMyDataSetElement(null); base.InnerList.Remove(value); this.OnCollectionChanged(System.EventArgs.Empty); } /// Removes the at the specific index from the collection. public new void RemoveAt(int index) { // Check to see if we have reached the minimum amount. if ((base.InnerList.Count == MinAmount)) { throw new System.ApplicationException("Minimum amount of items reached."); } this[index].SetParentMyDataSetElement(null); base.InnerList.RemoveAt(index); this.OnCollectionChanged(System.EventArgs.Empty); } /// This method is used to serialize the element collection to XML DOM. System.Xml.XmlElement[] IXmlElementCollection.GetXml(System.Xml.XmlDocument document) { if (((base.InnerList.Count != 0) && (base.InnerList.Count < MinAmount))) { throw new System.ApplicationException("Can not serialize element set since it does not comply with minimum / maximum amo" + "unts"); } System.Xml.XmlElement[] elements = new System.Xml.XmlElement[base.InnerList.Count]; for (int index = 0; (index < base.InnerList.Count); index = (index + 1)) { elements[index] = ((IXmlElement)(base.InnerList[index])).GetXml(document); } return elements; } /// This method is used to clone the collection. public object Clone() { CustomersCollection collection = new CustomersCollection(null); for (int index = 0; (index < base.InnerList.Count); index = (index + 1)) { collection.Add(((CustomersElement)(((CustomersElement)(base.InnerList[index])).Clone()))); } return collection; } /// Sets a value for the parent for all elements in this collection. protected internal void SetParentMyDataSetElement(MyDataSetElement parent) { for (int index = 0; (index < base.InnerList.Count); index = (index + 1)) { ((CustomersElement)(this[index])).SetParentMyDataSetElement(parent); } this.m_Parent = parent; } /// This method is used to check element collection equality. public override bool Equals(object obj) { if ((obj == null)) { return false; } try { for (int index = 0; (index < base.InnerList.Count); index = (index + 1)) { if ((this[index] != ((CustomersCollection)(obj))[index])) { return false; } } return true; } catch (System.ArgumentOutOfRangeException ) { return false; } catch (System.InvalidCastException ) { return false; } } /// Equality operator override. public static bool operator ==(CustomersCollection left, CustomersCollection right) { return (((((object)(left)) == null) && (((object)(right)) == null)) || ((((object)(left)) != null) && (left.Equals(right) == true))); } /// Equality operator override. public static bool operator !=(CustomersCollection left, CustomersCollection right) { return ((left == right) == false); } /// Invokes the event. public void OnCollectionChanged(System.EventArgs e) { if ((this.CollectionChanged != null)) { this.CollectionChanged(this, e); } } /// Serves as a hash function for the type, suitable for use in hashing algorithms and data structures like a hash table. public override int GetHashCode() { return base.GetHashCode(); } /// Used to catch insertions done via the interface. protected override void OnInsertComplete(int index, object value) { base.OnInsertComplete(index, value); this.OnCollectionChanged(System.EventArgs.Empty); } /// Used to catch clearing done via the interface. protected override void OnClearComplete() { base.OnClearComplete(); this.OnCollectionChanged(System.EventArgs.Empty); } /// Used to catch insertions done via the interface. protected override void OnRemoveComplete(int index, object value) { base.OnRemoveComplete(index, value); this.OnCollectionChanged(System.EventArgs.Empty); } /// Used to catch insertions done via the interface. protected override void OnSetComplete(int index, object oldValue, object newValue) { base.OnSetComplete(index, oldValue, newValue); this.OnCollectionChanged(System.EventArgs.Empty); } /// Used to catch insertions done via the interface. protected override void OnValidate(object value) { base.OnValidate(value); if (((value.GetType() != typeof(CustomersElement)) && (value.GetType().IsSubclassOf(typeof(CustomersElement)) == false))) { throw new System.ArgumentException(string.Concat("Can not convert type ", value.GetType().FullName, " to type CustomersElement.")); } } /// Gets objects from this collection according to their property. public CustomersElement[] GetByCustomerID(System.Decimal customerID) { System.Collections.ArrayList list = new System.Collections.ArrayList(); for (int index = 0; (index < this.Count); index = (index + 1)) { if (((this[index].IsCustomerIDNull != false) && (this[index].CustomerID == customerID))) { list.Add(this[index]); } } return ((CustomersElement[])(list.ToArray(typeof(CustomersElement)))); } /// Gets objects from this collection that have their properties set to null. public CustomersElement[] GetByCustomerIDNull() { System.Collections.ArrayList list = new System.Collections.ArrayList(); for (int index = 0; (index < this.Count); index = (index + 1)) { if ((this[index].IsCustomerIDNull == true)) { list.Add(this[index]); } } return ((CustomersElement[])(list.ToArray(typeof(CustomersElement)))); } /// Gets objects from this collection according to their property. public CustomersElement[] GetByCompanyName(string companyName) { System.Collections.ArrayList list = new System.Collections.ArrayList(); for (int index = 0; (index < this.Count); index = (index + 1)) { if ((this[index].CompanyName == companyName)) { list.Add(this[index]); } } return ((CustomersElement[])(list.ToArray(typeof(CustomersElement)))); } /// Gets objects from this collection according to their property. public CustomersElement[] GetByPhone(string phone) { System.Collections.ArrayList list = new System.Collections.ArrayList(); for (int index = 0; (index < this.Count); index = (index + 1)) { if ((this[index].Phone == phone)) { list.Add(this[index]); } } return ((CustomersElement[])(list.ToArray(typeof(CustomersElement)))); } } } /// This class is used to load and store files that contain the MyDataSet hierarchy. public class MyDataSetDocument : System.Xml.XmlDocument { /// This field is used to store the schema for validation. private static System.Xml.Schema.XmlSchema m_Schema = System.Xml.Schema.XmlSchema.Read(new System.IO.StringReader(@" "), null); /// This method is used for loading the MyDataSetDocument with data from the DOM. public static MyDataSetDocument FromDOM(MyDataSetElement element) { MyDataSetDocument document = new MyDataSetDocument(); document.AppendChild(document.CreateXmlDeclaration("1.0", "utf-8", "yes")); document.AppendChild(((IXmlElement)(element)).GetXml(document)); System.Xml.XmlAttribute xmlns = document.CreateAttribute("xmlns"); xmlns.Value = m_Schema.TargetNamespace; document[MyDataSetElement.ElementName].Attributes.Append(xmlns); return document; } /// This method is used for loading the DOM into this MyDataSetDocument. public MyDataSetElement CreateDOM() { return new MyDataSetElement(this[MyDataSetElement.ElementName]); } /// Loads the XML document from the specified and validates it against the schema. /// Note that if the namespace does not point to the schema, the document will not be validated. public override void Load(System.Xml.XmlReader reader) { System.Xml.XmlValidatingReader valReader; if ((reader.GetType() == typeof(System.Xml.XmlValidatingReader))) { valReader = ((System.Xml.XmlValidatingReader)(reader)); } else { valReader = new System.Xml.XmlValidatingReader(reader); } valReader.Schemas.Add(m_Schema); valReader.ValidationType = System.Xml.ValidationType.Schema; base.Load(reader); } } /// This interface is used for serializing the DOM, for an element collection. public interface IXmlElementCollection { /// This method is used to serialize an element collection to XML DOM. System.Xml.XmlElement[] GetXml(System.Xml.XmlDocument document); } /// This interface is used for serializing the DOM, for a specific element. public interface IXmlElement { /// This method is used to serialize an element to XML DOM. System.Xml.XmlElement GetXml(System.Xml.XmlDocument document); } }