´╗┐Option Explicit On
Option Strict On

Imports System
Imports 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\SimpleHierarchy\Schema\SimpleHierarchy.xsd
'**********************************************************************************************

Namespace SimpleHierarchyLib

    ''' <summary>
    ''' This class represents the ComplexType Payment
    ''' </summary>
    <LiquidTechnologies.Runtime.Net45.XmlObjectInfo(LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementGroupType.Choice, _
                                                    LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementType.Element, _
                                                    "Payment", "", true, false, _
                                                    LiquidTechnologies.Runtime.Net45.Conversions.ConversionType.type_none, Nothing, false)> _
    Public Partial Class Payment
        Inherits SimpleHierarchyLib.XmlCommonBase

        #Region "Constructors"
        ''' <summary>
        '''    Constructor for Payment
        ''' </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\SimpleHierarchy\Schema\SimpleHierarchy.xsd
        ''' </remarks>
        Public Sub New()
            _elementName = "Payment"
            Init()
        End Sub
        
        Public Sub New(ByVal elementName as String)
            _elementName = elementName
            Init()
        End Sub
        #End Region

        #Region "Initialization methods for the class"
        ''' <summary>
        '''    Initializes the class
        ''' </summary>
        ''' <remarks>
        '''    The 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\SimpleHierarchy\Schema\SimpleHierarchy.xsd.
        ''' </remarks>
        Protected Overrides Sub Init()
            SimpleHierarchyLib.Registration.iRegistrationIndicator = 0 ' causes registration to take place
            _VISA = Nothing
            _Vouchers = new SimpleHierarchyLib.XmlObjectCollection(Of SimpleHierarchyLib.Vouchers)("Vouchers", "", 1, -1, false)
            AddHandler _Vouchers.OnCollectionChange, AddressOf Me.Vouchers_OnChange
            _Cash = Nothing



            _validElement = ""
' ##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
        End Sub

        Protected Sub ClearChoice(ByVal selectedElement as string)
            _VISA = Nothing
            if (Not _Vouchers Is Nothing) Then
                if ("Vouchers" <> selectedElement) Then
                    _Vouchers.Clear()
                End If
            End If
            _Cash = Nothing
            _validElement = selectedElement
        End Sub
        #End Region

        #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 Overrides Function Clone() As Object
            Dim newObject As New SimpleHierarchyLib.Payment(_elementName)
            Dim o As Object
            newObject._VISA = Nothing
            if (Not _VISA Is Nothing) then
                newObject._VISA = CType(_VISA.Clone(), SimpleHierarchyLib.VISA)
            End If
            For Each o in _Vouchers
                newObject._Vouchers.Add(CType(CType(o, SimpleHierarchyLib.Vouchers).Clone(), SimpleHierarchyLib.Vouchers))
            Next o
            newObject._Cash = Nothing
            if (Not _Cash Is Nothing) Then
                newObject._Cash = CType(_Cash.Clone(), LiquidTechnologies.Runtime.Net45.Element)
            End If

            o = Nothing

            newObject._validElement = _validElement

' ##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
        End Function
        #End Region

        #Region "Member variables"

        Protected Overrides Readonly Property TargetNamespace() as String
            Get 
                Return ""
            End Get
        End Property

        #Region "Attribute - VISA"
        ''' <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.
        ''' Only one Element within this class may be set at a time, setting this property when another element is already set will raise an exception. setting this property to null will allow another element to be selected
        ''' </remarks>
        <LiquidTechnologies.Runtime.Net45.ElementInfoChoiceClsOpt("VISA", "", LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementType.Element, GetType(SimpleHierarchyLib.VISA))> _
        Public Property VISA() As SimpleHierarchyLib.VISA
            Get 
                Return _VISA  
            End Get
            Set(ByVal value As SimpleHierarchyLib.VISA) 
                ' The class represents a choice, so prevent more than one element from being selected
                If value Is Nothing Then ClearChoice("") Else ClearChoice("VISA") ' remove selection
                if (value Is Nothing) Then
                    _VISA = Nothing
                else
                    SetElementName(value, "VISA")
                    _VISA = value 
                End If
            End Set
        End Property
        Protected _VISA As SimpleHierarchyLib.VISA
        
        #End Region
    
        #Region "Attribute - Vouchers"
        ''' <summary>
        ''' A collection of Voucherss
        ''' </summary>
        ''' <remarks>
        ''' This property is represented as an Element in the XML.
        ''' This collection may contain 1 to Many objects.
        ''' Only one Element within this class may be set at a time. This collection (as a whole is counted as an element) may contain 0 or 1 to Many entries. Emptying the collection allows a different element to be the selected one. If there is already a selected element, and an item is added to this collection then an exception will be raised
        ''' </remarks>
        <LiquidTechnologies.Runtime.Net45.ElementInfoChoiceClsCol("Vouchers", "", LiquidTechnologies.Runtime.Net45.XmlObjectBase.XmlElementType.Element)> _
        Public Readonly Property Vouchers() As SimpleHierarchyLib.XmlObjectCollection(Of SimpleHierarchyLib.Vouchers)
            Get 
                Return _Vouchers 
            End Get
        End Property
        ' gets called when the collection changes (allows us to determine if this choice is selected or not)
        private Sub Vouchers_OnChange(ByVal o As object, ByVal args As EventArgs)
            ' The class represents a choice, so prevent more than one element from being selected
            if (_validElement <> "Vouchers") Then
                If _Vouchers.Count = 0 Then ClearChoice("") Else ClearChoice("Vouchers") ' remove selection
            End If
        End Sub
        Protected _Vouchers As SimpleHierarchyLib.XmlObjectCollection(Of SimpleHierarchyLib.Vouchers)
        
        #End Region
    
        #Region "Attribute - Cash"
        ''' <summary>
        ''' Represents an optional untyped element in the XML document
        ''' </summary>
        ''' <remarks>
        ''' It is optional, initially it is null.
        ''' Only one Element within this class may be set at a time, setting this property when another element is already set will raise an exception. setting this property to null will allow another element to be selected
        ''' </remarks>
        <LiquidTechnologies.Runtime.Net45.ElementInfoChoiceUntpdOpt("Cash", "", "##any", "")> _
        Public Property Cash() As LiquidTechnologies.Runtime.Net45.Element 
            Get 
                Return _Cash  
            End Get
            Set(ByVal value As LiquidTechnologies.Runtime.Net45.Element)
                if (Not value Is Nothing) Then
                    LiquidTechnologies.Runtime.Net45.Element.TestNamespace(value.Namespace, "##any", "")
                End If
                ' The class represents a choice, so prevent more than one element from being selected
                If value Is Nothing Then ClearChoice("") Else ClearChoice("Cash")
                _Cash = value 
            End Set
        End Property
        Protected _Cash As LiquidTechnologies.Runtime.Net45.Element
        #End Region
    
        Public Readonly Property ChoiceSelectedElement() As String 
            get 
                Return _validElement 
            End Get
        End Property
        Protected _validElement As String
        #Region "Attribute - Namespace"
        Public Overrides Readonly Property [Namespace]() As String
            Get 
                Return ""  
            End Get
        End Property
        #End Region

        #Region "Attribute - GetBase"
        Public Overrides Function GetBase() As LiquidTechnologies.Runtime.Net45.XmlObjectBase
            Return Me
        End Function
        #End Region
        #End Region


' ##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
    End Class
End Namespace