using System;
using System.Xml;

/**********************************************************************************************
 * Copyright (c) 2001-2017 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 15.0.1.7161
 * Using Schema: D:\Development2017\Liquid\Tools\DataBindingSamples\Samples\Cardinality\Schema\Cardinality.xsd
 **********************************************************************************************/

namespace CardinalityLib
{
    /// <summary>
    /// This class represents the Element MyRootObject
    /// </summary>
    [LiquidTechnologies.Runtime.Net45.XmlObjectInfo(LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementGroupType.Sequence,
                                                    LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementType.Element,
                                                    "MyRootObject", "", true, false,
                                                    LiquidTechnologies.Runtime.Net45.Conversions.ConversionType.type_none, null, false)]
    public partial class MyRootObject : CardinalityLib.XmlCommonBase
    {
        #region Constructors
        /// <summary>
        /// Constructor for MyRootObject
        /// </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 D:\Development2017\Liquid\Tools\DataBindingSamples\Samples\Cardinality\Schema\Cardinality.xsd
        /// </remarks>
        public MyRootObject()
        {
            _elementName = "MyRootObject";
            Init();
        }
        public MyRootObject(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 D:\Development2017\Liquid\Tools\DataBindingSamples\Samples\Cardinality\Schema\Cardinality.xsd.
        /// </remarks>
        protected override void Init()
        {
            CardinalityLib.Registration.iRegistrationIndicator = 0; // causes registration to take place
            m_ASimpleStringMandatoryElement = "";
            m_ASimpleDateMandatoryElement = new LiquidTechnologies.Runtime.Net45.XmlDateTime(LiquidTechnologies.Runtime.Net45.XmlDateTime.DateType.date);
            m_AComplexMandatoryElement = new CardinalityLib.AComplexMandatoryElement("AComplexMandatoryElement");
            m_ASimpleStringOptionalElement = "";
            m_IsValidASimpleStringOptionalElement = false;
            m_ASimpleDateOptionalElement = new LiquidTechnologies.Runtime.Net45.XmlDateTime(LiquidTechnologies.Runtime.Net45.XmlDateTime.DateType.date);
            m_IsValidASimpleDateOptionalElement = false;
            m_AComplexOptionalElement = null;
            m_ASimpleStringCollectionElement = new CardinalityLib.XmlSimpleTypeCollection<string>("ASimpleStringCollectionElement", "", LiquidTechnologies.Runtime.Net45.Conversions.ConversionType.type_string, 0, -1, null, LiquidTechnologies.Runtime.Net45.WhitespaceUtils.WhitespaceRule.Preserve, new LiquidTechnologies.Runtime.Net45.PrimitiveRestrictions("", "-1", "-1", "", "", "", "", "-1", "-1", "-1"));
            m_ASimpleDateCollectionElement = new CardinalityLib.XmlSimpleTypeCollection<LiquidTechnologies.Runtime.Net45.XmlDateTime>("ASimpleDateCollectionElement", "", LiquidTechnologies.Runtime.Net45.Conversions.ConversionType.type_date, 0, -1, null, LiquidTechnologies.Runtime.Net45.WhitespaceUtils.WhitespaceRule.Collapse, new LiquidTechnologies.Runtime.Net45.PrimitiveRestrictions("", "-1", "-1", "", "", "", "", "-1", "-1", "-1"));
            m_AComplexCollectionElement = new CardinalityLib.XmlObjectCollection<CardinalityLib.AComplexCollectionElement>("AComplexCollectionElement", "", 0, -1, false);

// ##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()
        {
            CardinalityLib.MyRootObject newObject = new CardinalityLib.MyRootObject(_elementName);
            newObject.m_ASimpleStringMandatoryElement = m_ASimpleStringMandatoryElement;
            newObject.m_ASimpleDateMandatoryElement = (LiquidTechnologies.Runtime.Net45.XmlDateTime)m_ASimpleDateMandatoryElement.Clone();
            newObject.m_AComplexMandatoryElement = null;
            if (m_AComplexMandatoryElement != null)
                newObject.m_AComplexMandatoryElement = (CardinalityLib.AComplexMandatoryElement)m_AComplexMandatoryElement.Clone();
            newObject.m_ASimpleStringOptionalElement = m_ASimpleStringOptionalElement;
            newObject.m_IsValidASimpleStringOptionalElement = m_IsValidASimpleStringOptionalElement;
            newObject.m_ASimpleDateOptionalElement = (LiquidTechnologies.Runtime.Net45.XmlDateTime)m_ASimpleDateOptionalElement.Clone();
            newObject.m_IsValidASimpleDateOptionalElement = m_IsValidASimpleDateOptionalElement;
            newObject.m_AComplexOptionalElement = null;
            if (m_AComplexOptionalElement != null)
                newObject.m_AComplexOptionalElement = (CardinalityLib.AComplexOptionalElement)m_AComplexOptionalElement.Clone();
            foreach (string o in m_ASimpleStringCollectionElement)
                newObject.m_ASimpleStringCollectionElement.Add(o);
            foreach (LiquidTechnologies.Runtime.Net45.XmlDateTime o in m_ASimpleDateCollectionElement)
                newObject.m_ASimpleDateCollectionElement.Add((LiquidTechnologies.Runtime.Net45.XmlDateTime)o.Clone());
            foreach (CardinalityLib.AComplexCollectionElement o in m_AComplexCollectionElement)
                newObject.m_AComplexCollectionElement.Add((CardinalityLib.AComplexCollectionElement)o.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 - ASimpleStringMandatoryElement
        /// <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.Net45.ElementInfoSeqPrimMnd("ASimpleStringMandatoryElement", "", null, LiquidTechnologies.Runtime.Net45.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.Net45.WhitespaceUtils.WhitespaceRule.Preserve, "", "-1", "-1", "", "", "", "", "-1", "-1", "-1")]
        public string ASimpleStringMandatoryElement
        {
            get
            {
                return m_ASimpleStringMandatoryElement;
            }
            set 
            {
                // Apply whitespace rules appropriately
                value = LiquidTechnologies.Runtime.Net45.WhitespaceUtils.Preserve(value);
                CheckElementRestriction(0, value);
                m_ASimpleStringMandatoryElement = value;
            }
        }
        protected string m_ASimpleStringMandatoryElement;

        #endregion

        #region Attribute - ASimpleDateMandatoryElement
        /// <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 new LiquidTechnologies.Runtime.Net45.XmlDateTime(LiquidTechnologies.Runtime.Net45.XmlDateTime.DateType.date).
        /// </remarks>
        [LiquidTechnologies.Runtime.Net45.ElementInfoSeqPrimMnd("ASimpleDateMandatoryElement", "", null, LiquidTechnologies.Runtime.Net45.Conversions.ConversionType.type_date, null, LiquidTechnologies.Runtime.Net45.WhitespaceUtils.WhitespaceRule.Collapse, "", "-1", "-1", "", "", "", "", "-1", "-1", "-1")]
        public LiquidTechnologies.Runtime.Net45.XmlDateTime ASimpleDateMandatoryElement
        {
            get
            {
                return m_ASimpleDateMandatoryElement;
            }
            set 
            {
                CheckElementRestriction(1, value);
                m_ASimpleDateMandatoryElement.SetDateTime(value, m_ASimpleDateMandatoryElement.Type); 
            }
        }
        protected LiquidTechnologies.Runtime.Net45.XmlDateTime m_ASimpleDateMandatoryElement;

        #endregion

        #region Attribute - AComplexMandatoryElement
        /// <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.Net45.ElementInfoSeqClsMnd("AComplexMandatoryElement", "", LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementType.Element, typeof(CardinalityLib.AComplexMandatoryElement), true)]
        public CardinalityLib.AComplexMandatoryElement AComplexMandatoryElement
        {
            get 
            { 
                return m_AComplexMandatoryElement;  
            }
            set 
            { 
                Throw_IfPropertyIsNull(value, "AComplexMandatoryElement");
                if (value != null)
                    SetElementName(value, "AComplexMandatoryElement");
                m_AComplexMandatoryElement = value;
            }
        }
        protected CardinalityLib.AComplexMandatoryElement m_AComplexMandatoryElement;
        
        #endregion

        #region Attribute - ASimpleStringOptionalElement
        /// <summary>
        /// Represents an optional Element in the XML document
        /// </summary>
        /// <remarks>
        /// This property is represented as an Element in the XML.
        /// It is optional, initially it is not valid.
        /// </remarks>
        [LiquidTechnologies.Runtime.Net45.ElementInfoSeqPrimOpt("ASimpleStringOptionalElement", "", "IsValidASimpleStringOptionalElement", null, LiquidTechnologies.Runtime.Net45.Conversions.ConversionType.type_string, null, LiquidTechnologies.Runtime.Net45.WhitespaceUtils.WhitespaceRule.Preserve, "", "-1", "-1", "", "", "", "", "-1", "-1", "-1")]
        public string ASimpleStringOptionalElement
        {
            get 
            { 
                if (m_IsValidASimpleStringOptionalElement == false)
                    throw new LiquidTechnologies.Runtime.Net45.LtInvalidStateException("The Property ASimpleStringOptionalElement is not valid. Set ASimpleStringOptionalElementValid = true");
                return m_ASimpleStringOptionalElement;  
            }
            set 
            { 
                CheckElementRestriction(3, value);
                // Apply whitespace rules appropriately
                value = LiquidTechnologies.Runtime.Net45.WhitespaceUtils.Preserve(value); 
                m_IsValidASimpleStringOptionalElement = true;
                m_ASimpleStringOptionalElement = value;
            }
        }
        /// <summary>
        /// Indicates if ASimpleStringOptionalElement contains a valid value.
        /// </summary>
        /// <remarks>
        /// true if the value for ASimpleStringOptionalElement is valid, false if not.
        /// If this is set to true then the property is considered valid, and assigned its
        /// default value ("").
        /// If its set to false then its made invalid, and subsequent calls to get ASimpleStringOptionalElement
        /// will raise an exception.
        /// </remarks>
        public bool IsValidASimpleStringOptionalElement
        {
            get
            {
                return m_IsValidASimpleStringOptionalElement;
            }
            set 
            { 
                if (value != m_IsValidASimpleStringOptionalElement)
                {
                    ASimpleStringOptionalElement = "";
                    m_IsValidASimpleStringOptionalElement = value;
                }
            }
        }
        protected bool m_IsValidASimpleStringOptionalElement;
        protected string m_ASimpleStringOptionalElement;
        #endregion

        #region Attribute - ASimpleDateOptionalElement
        /// <summary>
        /// Represents an optional Element in the XML document
        /// </summary>
        /// <remarks>
        /// This property is represented as an Element in the XML.
        /// It is optional, initially it is not valid.
        /// </remarks>
        [LiquidTechnologies.Runtime.Net45.ElementInfoSeqPrimOpt("ASimpleDateOptionalElement", "", "IsValidASimpleDateOptionalElement", null, LiquidTechnologies.Runtime.Net45.Conversions.ConversionType.type_date, null, LiquidTechnologies.Runtime.Net45.WhitespaceUtils.WhitespaceRule.Collapse, "", "-1", "-1", "", "", "", "", "-1", "-1", "-1")]
        public LiquidTechnologies.Runtime.Net45.XmlDateTime ASimpleDateOptionalElement
        {
            get 
            { 
                if (m_IsValidASimpleDateOptionalElement == false)
                    throw new LiquidTechnologies.Runtime.Net45.LtInvalidStateException("The Property ASimpleDateOptionalElement is not valid. Set ASimpleDateOptionalElementValid = true");
                return m_ASimpleDateOptionalElement;  
            }
            set 
            { 
                CheckElementRestriction(4, value);
                m_IsValidASimpleDateOptionalElement = true;
                m_ASimpleDateOptionalElement.SetDateTime(value, m_ASimpleDateOptionalElement.Type); 
            }
        }
        /// <summary>
        /// Indicates if ASimpleDateOptionalElement contains a valid value.
        /// </summary>
        /// <remarks>
        /// true if the value for ASimpleDateOptionalElement is valid, false if not.
        /// If this is set to true then the property is considered valid, and assigned its
        /// default value (new LiquidTechnologies.Runtime.Net45.XmlDateTime(LiquidTechnologies.Runtime.Net45.XmlDateTime.DateType.date)).
        /// If its set to false then its made invalid, and subsequent calls to get ASimpleDateOptionalElement
        /// will raise an exception.
        /// </remarks>
        public bool IsValidASimpleDateOptionalElement
        {
            get
            {
                return m_IsValidASimpleDateOptionalElement;
            }
            set 
            { 
                if (value != m_IsValidASimpleDateOptionalElement)
                {
                    ASimpleDateOptionalElement = new LiquidTechnologies.Runtime.Net45.XmlDateTime(LiquidTechnologies.Runtime.Net45.XmlDateTime.DateType.date);
                    m_IsValidASimpleDateOptionalElement = value;
                }
            }
        }
        protected bool m_IsValidASimpleDateOptionalElement;
        protected LiquidTechnologies.Runtime.Net45.XmlDateTime m_ASimpleDateOptionalElement;
        #endregion

        #region Attribute - AComplexOptionalElement
        /// <summary>
        /// Represents an optional Element in the XML document
        /// </summary>
        /// <remarks>
        /// This property is represented as an Element in the XML.
        /// It is optional, initially it is null.
        /// </remarks>
        [LiquidTechnologies.Runtime.Net45.ElementInfoSeqClsOpt("AComplexOptionalElement", "", LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementType.Element, typeof(CardinalityLib.AComplexOptionalElement))]
        public CardinalityLib.AComplexOptionalElement AComplexOptionalElement
        {
            get
            { 
                return m_AComplexOptionalElement;
            }
            set
            { 
                if (value == null)
                    m_AComplexOptionalElement = null;
                else
                {
                    SetElementName(value, "AComplexOptionalElement");
                    m_AComplexOptionalElement = value; 
                }
            }
        }
        protected CardinalityLib.AComplexOptionalElement m_AComplexOptionalElement;
        
        #endregion

        #region Attribute - ASimpleStringCollectionElement
        /// <summary>
        /// A collection of strings
        /// </summary>
        /// <remarks>
        /// This property is represented as an Element in the XML.
        /// This collection may contain 0 to Many strings.
        /// </remarks>
        [LiquidTechnologies.Runtime.Net45.ElementInfoSeqPrimCol("ASimpleStringCollectionElement", "")]
        public CardinalityLib.XmlSimpleTypeCollection<string> ASimpleStringCollectionElement
        {
            get { return m_ASimpleStringCollectionElement; }
        }
        protected CardinalityLib.XmlSimpleTypeCollection<string> m_ASimpleStringCollectionElement;

        #endregion

        #region Attribute - ASimpleDateCollectionElement
        /// <summary>
        /// A collection of LiquidTechnologies.Runtime.Net45.XmlDateTimes
        /// </summary>
        /// <remarks>
        /// This property is represented as an Element in the XML.
        /// This collection may contain 0 to Many LiquidTechnologies.Runtime.Net45.XmlDateTimes.
        /// </remarks>
        [LiquidTechnologies.Runtime.Net45.ElementInfoSeqPrimCol("ASimpleDateCollectionElement", "")]
        public CardinalityLib.XmlSimpleTypeCollection<LiquidTechnologies.Runtime.Net45.XmlDateTime> ASimpleDateCollectionElement
        {
            get { return m_ASimpleDateCollectionElement; }
        }
        protected CardinalityLib.XmlSimpleTypeCollection<LiquidTechnologies.Runtime.Net45.XmlDateTime> m_ASimpleDateCollectionElement;

        #endregion

        #region Attribute - AComplexCollectionElement
        /// <summary>
        /// A collection of AComplexCollectionElements
        /// </summary>
        /// <remarks>
        /// This property is represented as an Element in the XML.
        /// This collection may contain 0 to Many objects.
        /// </remarks>
        [LiquidTechnologies.Runtime.Net45.ElementInfoSeqClsCol("AComplexCollectionElement", "", LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementType.Element)]
        public CardinalityLib.XmlObjectCollection<CardinalityLib.AComplexCollectionElement> AComplexCollectionElement
        {
            get { return m_AComplexCollectionElement; }
        }
        protected CardinalityLib.XmlObjectCollection<CardinalityLib.AComplexCollectionElement> m_AComplexCollectionElement;

        #endregion

        #region Attribute - Namespace
        public override string Namespace
        {
            get { return ""; }
        }    
        #endregion    

        #region Attribute - GetBase
        public override LiquidTechnologies.Runtime.Net45.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
    }
}