VERSION 1.0 CLASS
BEGIN   
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "AComplexCoionElementCol"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'**********************************************************************************************
'* 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
'**********************************************************************************************
Private m_elementName         as String
Private m_elementNamespaceUri As String 
Private m_minOccurs           as Long
Private m_maxOccurs           as Long
Private m_coll                as Collection

' ##HAND_CODED_BLOCK_START ID="Additional Variable Declarations"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

' Add Additional Variable Declarations...

' ##HAND_CODED_BLOCK_END ID="Additional Variable Declarations"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

Public Event OnCollectionChange()

Implements LtXmlComLib15.XmlCollectionBase
Implements LtXmlComLib15.XmlObjectBase

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''' Collection Methods ''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Summary:
'       Adds a AComplexCollctionElement enumeration to the collection
' Param name="newEnum":
'       The object to be copied into the collection
' Returns:
'       The copied object (that was added to the collection)
' Remarks:
'       The object newProperty, is copied, and the copy is added to the
'       collection.
public Function Add(ByVal newCls as CardinalityLib.AComplexCollctionElement, optional Before, optional After) as CardinalityLib.AComplexCollctionElement 
    CastToXmlObjectBase(newCls).PrivateSetElementName m_elementName
'   LtXmlComLib15.XmlObjectBaseHelper.Throw_IfElementNameDiffers newCls, m_elementName
    m_coll.Add newCls, , Before, After
    RaiseEvent OnCollectionChange
    Set Add = newCls
End Function 
        
' Summary:
'       Adds a AComplexCollctionElement object to the collection
' Returns:
'       The newly created AComplexCollctionElement object
' Remarks:
'       A new AComplexCollctionElement object is created and added to the collection
'       the new object is then returned.
public Function AddNew() as CardinalityLib.AComplexCollctionElement 
    Set AddNew = CF.CreateClass(ClsName_AComplexCollctionElement)
    CastToXmlObjectBase(AddNew).PrivateSetElementName m_elementName
    m_coll.Add AddNew
    RaiseEvent OnCollectionChange
End Function

' Summary:
'       Gets a AComplexCollctionElement object from the collection
' Param name="index":
'       The 0 based index of the item to retreve
' Returns:
'       The object at the given location in the collection
public property Get Item(byval index as long) as CardinalityLib.AComplexCollctionElement 
Attribute Item.VB_UserMemId = 0
    Set Item = m_Coll(index)
End Property

Public Property Get Count() As Long
     Count = m_coll.Count
End Property


Public Sub Remove(ByVal index As Long)
    m_coll.Remove index
    RaiseEvent OnCollectionChange
End Sub

Public Sub Clear()
    while m_coll.Count > 0
        Remove 1
    wend
End Sub

Public Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"
     Set NewEnum = m_Coll.[_NewEnum]
End Property

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''' Implementation of Class'''' '''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
Private Sub Class_Initialize()
    set m_coll = new Collection
End Sub

Private Sub Class_Terminate()
    Set m_coll = nothing
End Sub


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''' Implementation of XmlObjectBase '''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Property Get XmlObjectBase_ElementName() As String
    XmlObjectBase_ElementName = m_elementName
End Property

Private Function XmlObjectBase_IsSuitableSubstitution(ByVal InterfaceName As String) As Boolean
    XmlObjectBase_IsSuitableSubstitution = false
    if InterfaceName = "AComplexCollctionElement" _
        then XmlObjectBase_IsSuitableSubstitution = true
End Function

Private Sub XmlObjectBase_PrivateSetElementName(ByVal vNewValue As String)
    m_ElementName = vNewValue
End Sub

Private Sub XmlObjectBase_AttributesToXmlInt(ByVal xmlOut As LtXmlComLib15.XmlTextWriter, ByVal oContext As LtXmlComLib15.XmlSerializationContext)
    dim oCls as LtXmlComLib15.XmlObjectBase
    
    for each oCls in m_coll
        CastToXmlObjectBase(oCls).AttributesToXmlInt xmlOut, oContext
    next 
End Sub

Private Sub XmlObjectBase_ToXmlInt(ByVal xmlOut As LtXmlComLib15.XmlTextWriter, ByVal bRegisterNamespaces As Boolean, ByVal NamespaceURI As String, ByVal oContext As LtXmlComLib15.XmlSerializationContext, ByVal isOptionalChoice As Boolean)
    dim oCls as LtXmlComLib15.XmlObjectBase
    
    XmlCollectionBase_ValidateCount oContext
    
    for each oCls in m_coll
        CastToXmlObjectBase(oCls).ToXmlInt xmlOut, false, NamespaceUri, oContext, isOptionalChoice
    next 
End Sub

Private Function XmlObjectBase_FromXmlInt(ByVal xmlParent As MSXML2.IXMLDOMElement, ByVal xmlChild As MSXML2.IXMLDOMElement, ByVal oContext As LtXmlComLib15.XmlSerializationContext, ByVal isOptionalChoice As Boolean) As MSXML2.IXMLDOMElement
    Dim newObj as CardinalityLib.AComplexCollctionElement 
    ' go through the nodes until we run out of ones that match
    do while not xmlChild is nothing
        if xmlChild.NodeType = MSXML2.NODE_ELEMENT then
            ' Stop reading when we hit an element we can't deal with
            if LtXmlComLib15.XmlGeneratedClassHelper.DoesElementNameMatch(oContext, xmlChild, m_elementName, m_elementNamespaceUri) = False then exit do
            Set newObj = CF.CreateNamedClass(ClsName_AComplexCollctionElement, m_elementName)
            CastToXmlObjectBase(newObj).FromXmlInt xmlChild, LtXmlComLib15.XmlObjectBaseHelper.FindFirstSliblingElement(xmlChild.FirstChild), oContext, isOptionalChoice

            ' Add new item to the collection
            m_coll.Add newObj
            RaiseEvent OnCollectionChange
        end if
        
        ' Move to next node
        Set xmlChild = LtXmlComLib15.XmlObjectBaseHelper.MoveNextSiblingElement(xmlChild)
    loop 
    
    Set XmlObjectBase_FromXmlInt = xmlChild
End Function


Private Property Get XmlObjectBase_TargetNamespace() As String
    XmlObjectBase_TargetNamespace = ""
End Property

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''' Implementation of XmlCollectionBase '''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' we don't want the users just creating these. They need to 
' be initialize with the name of the element that they are
' going to represent in the XML document. This information
' requires knowledge of the schema, we are trying to 
' prevent the user from having to know anything about that. 
Private Sub XmlCollectionBase_Init(ByVal strElementName As String, ByVal strElementNamespaceUri As String, ByVal iMinOccurs As Long, ByVal iMaxOccurs As Long)
    m_elementName          = strElementName
    m_elementNamespaceUri  = strElementNamespaceUri
    m_minOccurs            = iMinOccurs
    m_maxOccurs            = iMaxOccurs
End Sub

Private Sub XmlCollectionBase_ValidateCount(ByVal oContext As XmlSerializationContext)
    XmlObjectBaseHelper.ValidateCountHelper oContext, m_coll, m_minOccurs, m_maxOccurs, m_ElementName
End Sub

Private Property Get XmlCollectionBase_MinOccurs() As Long
    XmlCollectionBase_MinOccurs = m_minOccurs
End Property

' ##HAND_CODED_BLOCK_START ID="Additional Methods/Properties"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

' Add Additional Methods/Properties Here...

' ##HAND_CODED_BLOCK_END ID="Additional Methods/Properties"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS