C# Sample : Derived By Extension
Schema Summary This sample shows how a complex type may be extended, and how the base and extended types can be manipulated in code. Schema Details The Schema A global base type Address is defined (all base types must be global). The elements CAN_Address and GBR_Address then extended Address in order to add additional elements. The Person element contains a child element HomeAddress of type Address. In place of Address any type that is based on Address (including Address itself) can be used (CAN_Address and GBR_Address). If an element is added to Person:HomeAddress of a type other than the Address, then we need to identify the type of the element used (for validation purposes), this means placing a xs:type="" attribute against the element. This is automatically done for you by the generated classes. Generated Code The element Address is a base element to CAN_Address and GBR_Address, and Address can be created as an element in its own right. This means that where ever Address can be used CAN_Address and GBR_Address can be used in its place. In order to implement this in the generated code, an abstract base class IAddress is introduced. All of the classes generated from Address, CAN_Address and GBR_Address implement this IAddress interface. Sample Description The sample demonstrates the use of the derived type GBR_Address. Note the type specified in Person is 'Address' however any element deriving from it may used in its place. |
Sample XML File
Sample2.xml |
<?xml version="1.0" encoding="UTF-8"?> <Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="..\Schema\DerivedByExtension.xsd" > <Age>32</Age> <HomeAddress xsi:type="GBR_Address"> <Name>Joe Bloggs</Name> <Street>The Head row</Street> <City>Leeds</City> <County>West Yorkshire</County> <PostCode>LS8 4BD</PostCode> </HomeAddress> </Person> |
Read Sample | |
SampleRead(MainCls.SamplePath + "DerivedByExtension\\Samples\\Sample2.xml"); // Create Name object DerivedByExtensionLib.Person per = new DerivedByExtensionLib.Person(); // Load data into the object from a file per.FromXmlFile(FilePath); // Now we can look at the data Console.WriteLine("Age = {0}", per.Age); Console.WriteLine("Address"); Console.WriteLine(" Name = {0}", per.HomeAddress.Name); Console.WriteLine(" Street = {0}", per.HomeAddress.Street); Console.WriteLine(" City = {0}", per.HomeAddress.City); if (per.HomeAddress.GetType() == typeof(DerivedByExtensionLib.Address)) { // The HomeAddress is an Address object, there is no more data to display } else if (per.HomeAddress.GetType() == typeof(DerivedByExtensionLib.CAN_Address)) { // The HomeAddress is an CAN_Address object Console.WriteLine(" City = {0}", ((DerivedByExtensionLib.CAN_Address)per.HomeAddress).Province); Console.WriteLine(" PostalCode = {0}", ((DerivedByExtensionLib.CAN_Address)per.HomeAddress).PostalCode); } else if (per.HomeAddress.GetType() == typeof(DerivedByExtensionLib.GBR_Address)) { // The HomeAddress is an GBR_Address object Console.WriteLine(" County = {0}", ((DerivedByExtensionLib.GBR_Address)per.HomeAddress).County); Console.WriteLine(" PostCode = {0}", ((DerivedByExtensionLib.GBR_Address)per.HomeAddress).PostCode); } else { // The HomeAddress is an unknown type Console.WriteLine("The Home address is an unknown type {0}", per.HomeAddress.GetType().FullName); }
|
Write Sample | |
// Create Name object DerivedByExtensionLib.Person per = new DerivedByExtensionLib.Person(); // populate the person object per.Age = 32; // Create the right kind of address object per.HomeAddress = new DerivedByExtensionLib.GBR_Address(); ((DerivedByExtensionLib.GBR_Address)per.HomeAddress).Name = "Joe Bloggs"; ((DerivedByExtensionLib.GBR_Address)per.HomeAddress).Street = "The Head row"; ((DerivedByExtensionLib.GBR_Address)per.HomeAddress).City = "Leeds"; ((DerivedByExtensionLib.GBR_Address)per.HomeAddress).County = "West Yorkshire"; ((DerivedByExtensionLib.GBR_Address)per.HomeAddress).PostCode = "LS8 4BD"; // Now we can look at the XML from this object Console.WriteLine(per.ToXml(true, System.Xml.Formatting.Indented, LiquidTechnologies.Runtime.EOLType.CRLF));
|
DerivedByExtension.xsd |
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="Address"> <xs:sequence> <xs:element name="Name" type="xs:string"/> <xs:element name="Street" type="xs:string"/> <xs:element name="City" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="CAN_Address"> <xs:complexContent> <xs:extension base="Address"> <xs:sequence> <xs:element name="Province" type="xs:string"/> <xs:element name="PostalCode" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="GBR_Address"> <xs:complexContent> <xs:extension base="Address"> <xs:sequence> <xs:element name="County" type="xs:string"/> <xs:element name="PostCode" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:element name="Person"> <xs:complexType> <xs:sequence> <xs:element name="Age" type="xs:unsignedByte"/> <xs:element name="HomeAddress" type="Address"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> |
Schema Diagrams |
|
Address.cs |
���using System; using System.Xml; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ namespace DerivedByExtensionLib { /// <summary> /// This class represents the ComplexType Address /// </summary> [LiquidTechnologies.Runtime.XmlObjectInfo(LiquidTechnologies.Runtime.XmlObjectBase.XmlElementGroupType.Sequence, LiquidTechnologies.Runtime.XmlObjectBase.XmlElementType.Element, "Address", "", true, true, false)] public partial class Address : DerivedByExtensionLib.XmlCommonBase , DerivedByExtensionLib.IAddress { #region Constructors /// <summary> /// Constructor for Address /// </summary> /// <remarks> /// The class is created with all the mandatory fields populated with the /// default data. /// All Collection object are created. /// However any 1-n relationships (these are represented as collections) are /// empty. To comply with the schema these must be populated before the xml /// obtained from ToXml is valid against the schema DerivedByExtension.xsd /// </remarks> public Address() { _elementName = "Address"; Init(); } public Address(string elementName) { _elementName = elementName; Init(); } #endregion #region Initialization methods for the class /// <summary> /// Initializes the class /// </summary> /// <remarks> /// This creates all the mandatory fields (populated with the default data) /// All Collection object are created. /// However any 1-n relationships (these are represented as collections) are /// empty. To comply with the schema these must be populated before the xml /// obtained from ToXml is valid against the schema DerivedByExtension.xsd. /// </remarks> protected override void Init() { DerivedByExtensionLib.Registration.iRegistrationIndicator = 0; // causes registration to take place m_Name = ""; m_Street = ""; m_City = ""; // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional initialization code here... // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } #endregion #region ICloneable Interface /// <summary> /// Allows the class to be copied /// </summary> /// <remarks> /// Performs a 'deep copy' of all the data in the class (and its children) /// </remarks> public override object Clone() { DerivedByExtensionLib.Address newObject = new DerivedByExtensionLib.Address(_elementName); newObject.m_Name = m_Name; newObject.m_Street = m_Street; newObject.m_City = m_City; // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional clone code here... // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS return newObject; } #endregion #region Member variables protected override string TargetNamespace { get { return ""; } } #region Attribute - Name /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("Name", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string Name { get { return m_Name; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_Name = value; } } protected string m_Name; #endregion #region Attribute - Street /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("Street", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string Street { get { return m_Street; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_Street = value; } } protected string m_Street; #endregion #region Attribute - City /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("City", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string City { get { return m_City; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_City = value; } } protected string m_City; #endregion #region Attribute - Namespace public override string Namespace { get { return ""; } } #endregion #region Attribute - GetBase public override LiquidTechnologies.Runtime.XmlObjectBase GetBase() { return this; } #endregion #endregion // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } } |
CAN_Address.cs |
���using System; using System.Xml; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ namespace DerivedByExtensionLib { /// <summary> /// This class represents the ComplexType CAN_Address /// </summary> [LiquidTechnologies.Runtime.XmlObjectInfo(LiquidTechnologies.Runtime.XmlObjectBase.XmlElementGroupType.Sequence, LiquidTechnologies.Runtime.XmlObjectBase.XmlElementType.Element, "CAN_Address", "", true, true, false)] public partial class CAN_Address : DerivedByExtensionLib.XmlCommonBase , DerivedByExtensionLib.IAddress { #region Constructors /// <summary> /// Constructor for CAN_Address /// </summary> /// <remarks> /// The class is created with all the mandatory fields populated with the /// default data. /// All Collection object are created. /// However any 1-n relationships (these are represented as collections) are /// empty. To comply with the schema these must be populated before the xml /// obtained from ToXml is valid against the schema DerivedByExtension.xsd /// </remarks> public CAN_Address() { _elementName = "CAN_Address"; Init(); } public CAN_Address(string elementName) { _elementName = elementName; Init(); } #endregion #region Initialization methods for the class /// <summary> /// Initializes the class /// </summary> /// <remarks> /// This creates all the mandatory fields (populated with the default data) /// All Collection object are created. /// However any 1-n relationships (these are represented as collections) are /// empty. To comply with the schema these must be populated before the xml /// obtained from ToXml is valid against the schema DerivedByExtension.xsd. /// </remarks> protected override void Init() { DerivedByExtensionLib.Registration.iRegistrationIndicator = 0; // causes registration to take place m_Name = ""; m_Street = ""; m_City = ""; m_Province = ""; m_PostalCode = ""; // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional initialization code here... // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } #endregion #region ICloneable Interface /// <summary> /// Allows the class to be copied /// </summary> /// <remarks> /// Performs a 'deep copy' of all the data in the class (and its children) /// </remarks> public override object Clone() { DerivedByExtensionLib.CAN_Address newObject = new DerivedByExtensionLib.CAN_Address(_elementName); newObject.m_Name = m_Name; newObject.m_Street = m_Street; newObject.m_City = m_City; newObject.m_Province = m_Province; newObject.m_PostalCode = m_PostalCode; // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional clone code here... // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS return newObject; } #endregion #region Member variables protected override string TargetNamespace { get { return ""; } } #region Attribute - Name /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("Name", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string Name { get { return m_Name; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_Name = value; } } protected string m_Name; #endregion #region Attribute - Street /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("Street", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string Street { get { return m_Street; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_Street = value; } } protected string m_Street; #endregion #region Attribute - City /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("City", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string City { get { return m_City; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_City = value; } } protected string m_City; #endregion #region Attribute - Province /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("Province", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string Province { get { return m_Province; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_Province = value; } } protected string m_Province; #endregion #region Attribute - PostalCode /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("PostalCode", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string PostalCode { get { return m_PostalCode; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_PostalCode = value; } } protected string m_PostalCode; #endregion #region Attribute - Namespace public override string Namespace { get { return ""; } } #endregion #region Attribute - GetBase public override LiquidTechnologies.Runtime.XmlObjectBase GetBase() { return this; } #endregion #endregion // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } } |
GBR_Address.cs |
���using System; using System.Xml; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ namespace DerivedByExtensionLib { /// <summary> /// This class represents the ComplexType GBR_Address /// </summary> [LiquidTechnologies.Runtime.XmlObjectInfo(LiquidTechnologies.Runtime.XmlObjectBase.XmlElementGroupType.Sequence, LiquidTechnologies.Runtime.XmlObjectBase.XmlElementType.Element, "GBR_Address", "", true, true, false)] public partial class GBR_Address : DerivedByExtensionLib.XmlCommonBase , DerivedByExtensionLib.IAddress { #region Constructors /// <summary> /// Constructor for GBR_Address /// </summary> /// <remarks> /// The class is created with all the mandatory fields populated with the /// default data. /// All Collection object are created. /// However any 1-n relationships (these are represented as collections) are /// empty. To comply with the schema these must be populated before the xml /// obtained from ToXml is valid against the schema DerivedByExtension.xsd /// </remarks> public GBR_Address() { _elementName = "GBR_Address"; Init(); } public GBR_Address(string elementName) { _elementName = elementName; Init(); } #endregion #region Initialization methods for the class /// <summary> /// Initializes the class /// </summary> /// <remarks> /// This creates all the mandatory fields (populated with the default data) /// All Collection object are created. /// However any 1-n relationships (these are represented as collections) are /// empty. To comply with the schema these must be populated before the xml /// obtained from ToXml is valid against the schema DerivedByExtension.xsd. /// </remarks> protected override void Init() { DerivedByExtensionLib.Registration.iRegistrationIndicator = 0; // causes registration to take place m_Name = ""; m_Street = ""; m_City = ""; m_County = ""; m_PostCode = ""; // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional initialization code here... // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } #endregion #region ICloneable Interface /// <summary> /// Allows the class to be copied /// </summary> /// <remarks> /// Performs a 'deep copy' of all the data in the class (and its children) /// </remarks> public override object Clone() { DerivedByExtensionLib.GBR_Address newObject = new DerivedByExtensionLib.GBR_Address(_elementName); newObject.m_Name = m_Name; newObject.m_Street = m_Street; newObject.m_City = m_City; newObject.m_County = m_County; newObject.m_PostCode = m_PostCode; // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional clone code here... // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS return newObject; } #endregion #region Member variables protected override string TargetNamespace { get { return ""; } } #region Attribute - Name /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("Name", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string Name { get { return m_Name; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_Name = value; } } protected string m_Name; #endregion #region Attribute - Street /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("Street", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string Street { get { return m_Street; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_Street = value; } } protected string m_Street; #endregion #region Attribute - City /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("City", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string City { get { return m_City; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_City = value; } } protected string m_City; #endregion #region Attribute - County /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("County", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string County { get { return m_County; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_County = value; } } protected string m_County; #endregion #region Attribute - PostCode /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to "". /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("PostCode", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Preserve, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public string PostCode { get { return m_PostCode; } set { // Apply whitespace rules appropriately value = LiquidTechnologies.Runtime.WhitespaceUtils.Preserve(value); m_PostCode = value; } } protected string m_PostCode; #endregion #region Attribute - Namespace public override string Namespace { get { return ""; } } #endregion #region Attribute - GetBase public override LiquidTechnologies.Runtime.XmlObjectBase GetBase() { return this; } #endregion #endregion // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } } |
IAddress.cs |
���using System; using System.Xml; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ namespace DerivedByExtensionLib { /// <summary> /// </summary> public interface IAddress : LiquidTechnologies.Runtime.XmlObjectInterface { #region Member variables #region Attribute - Name /// <summary> /// Represents a mandatory Element in the XML document /// </summary> string Name { get; set; } #endregion #region Attribute - Street /// <summary> /// Represents a mandatory Element in the XML document /// </summary> string Street { get; set; } #endregion #region Attribute - City /// <summary> /// Represents a mandatory Element in the XML document /// </summary> string City { get; set; } #endregion #endregion // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } } |
Person.cs |
���using System; using System.Xml; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ namespace DerivedByExtensionLib { /// <summary> /// This class represents the Element Person /// </summary> [LiquidTechnologies.Runtime.XmlObjectInfo(LiquidTechnologies.Runtime.XmlObjectBase.XmlElementGroupType.Sequence, LiquidTechnologies.Runtime.XmlObjectBase.XmlElementType.Element, "Person", "", true, false, false)] public partial class Person : DerivedByExtensionLib.XmlCommonBase { #region Constructors /// <summary> /// Constructor for Person /// </summary> /// <remarks> /// The class is created with all the mandatory fields populated with the /// default data. /// All Collection object are created. /// However any 1-n relationships (these are represented as collections) are /// empty. To comply with the schema these must be populated before the xml /// obtained from ToXml is valid against the schema DerivedByExtension.xsd /// </remarks> public Person() { _elementName = "Person"; Init(); } public Person(string elementName) { _elementName = elementName; Init(); } #endregion #region Initialization methods for the class /// <summary> /// Initializes the class /// </summary> /// <remarks> /// This creates all the mandatory fields (populated with the default data) /// All Collection object are created. /// However any 1-n relationships (these are represented as collections) are /// empty. To comply with the schema these must be populated before the xml /// obtained from ToXml is valid against the schema DerivedByExtension.xsd. /// </remarks> protected override void Init() { DerivedByExtensionLib.Registration.iRegistrationIndicator = 0; // causes registration to take place m_Age = 0; m_HomeAddress = null; // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional initialization code here... // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } #endregion #region ICloneable Interface /// <summary> /// Allows the class to be copied /// </summary> /// <remarks> /// Performs a 'deep copy' of all the data in the class (and its children) /// </remarks> public override object Clone() { DerivedByExtensionLib.Person newObject = new DerivedByExtensionLib.Person(_elementName); newObject.m_Age = m_Age; newObject.m_HomeAddress = null; if (m_HomeAddress != null) newObject.m_HomeAddress = (DerivedByExtensionLib.IAddress)m_HomeAddress.Clone(); // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional clone code here... // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS return newObject; } #endregion #region Member variables protected override string TargetNamespace { get { return ""; } } #region Attribute - Age /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// It is defaulted to 0. /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqPrimMnd("Age", "", null, LiquidTechnologies.Runtime.Conversions.ConversionType.type_ui1, null, LiquidTechnologies.Runtime.WhitespaceUtils.WhitespaceRule.Collapse, "", -1, -1, "", "", "", "", -1, -1, -1, null)] public byte Age { get { return m_Age; } set { m_Age = value; } } protected byte m_Age; #endregion #region Attribute - HomeAddress /// <summary> /// Represents a mandatory Element in the XML document /// </summary> /// <remarks> /// This property is represented as an Element in the XML. /// It is mandatory and therefore must be populated within the XML. /// If this property is set, then the object will be COPIED. If the property is set to null an exception is raised. /// </remarks> [LiquidTechnologies.Runtime.ElementInfoSeqAbsClsMnd("HomeAddress", "", LiquidTechnologies.Runtime.XmlObjectBase.XmlElementType.Element, typeof(DerivedByExtensionLib.ClassFactory), "IAddressCreateObject")] public DerivedByExtensionLib.IAddress HomeAddress { get { return m_HomeAddress; } set { Throw_IfPropertyIsNull(value, "HomeAddress"); if (value != null) { // The object being set needs to take the element name from the class (the type="" attribute will then be set in the XML) SetElementName(value.GetBase(), "HomeAddress"); } m_HomeAddress = value; } } protected DerivedByExtensionLib.IAddress m_HomeAddress; #endregion #region Attribute - Namespace public override string Namespace { get { return ""; } } #endregion #region Attribute - GetBase public override LiquidTechnologies.Runtime.XmlObjectBase GetBase() { return this; } #endregion #endregion // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } } |
Main Menu | Samples List |