In This Topic
    ClassFactory.cls
    In This Topic
    VERSION 1.0 CLASS
    BEGIN   
      MultiUse = -1  'True
      Persistable = 0  'NotPersistable
      DataBindingBehavior = 0  'vbNone
      DataSourceBehavior  = 0  'vbNone
      MTSTransactionMode  = 0  'NotAnMTSObject
    END
    Attribute VB_Name = "ClassFactory"
    Attribute VB_GlobalNameSpace = True
    Attribute VB_Creatable = True
    Attribute VB_PredeclaredId = False
    Attribute VB_Exposed = True
    Option Explicit
    '**********************************************************************************************
    '* 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: MusicStore.xsd
    '**********************************************************************************************
    Private mvarEnumConverter as new EnumConversions
    
    ' ##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 enum MusicStoreLib_Classes
        ClsName_NONE
         ClsName_AlbumType
         ClsName_Error_
         ClsName_PriceFilter
         ClsName_Result
         ClsName_SearchRequest
         ClsName_SearchResponse
         ClsName_TrackType
         ClsName_AlbumTypeCol
         ClsName_TrackTypeCol
    End Enum
    
    Public Function CreateClass(ByVal eCls as MusicStoreLib_Classes) as LtXmlComLib20.XmlObjectBase
        ' This is structured like this to get around compiler limitations
        if eCls = ClsName_NONE then
            Err.Raise 1, "ClassFactory", "Invalid Class (NONE)"
        end if
        
        Select Case (eCls)
        case ClsName_AlbumType
            Set CreateClass = new MusicStoreLib.AlbumType
        case ClsName_Error_
            Set CreateClass = new MusicStoreLib.Error_
        case ClsName_PriceFilter
            Set CreateClass = new MusicStoreLib.PriceFilter
        case ClsName_Result
            Set CreateClass = new MusicStoreLib.Result
        case ClsName_SearchRequest
            Set CreateClass = new MusicStoreLib.SearchRequest
        case ClsName_SearchResponse
            Set CreateClass = new MusicStoreLib.SearchResponse
        case ClsName_TrackType
            Set CreateClass = new MusicStoreLib.TrackType
        case else
            Err.Raise 2, "ClassFactory", "Unknown Class id"
        End Select
        
        Debug.Assert not CreateClass is nothing
    End Function
    
    Public Function CreateNamedClass(byval eCls as MusicStoreLib_Classes, byval strElementName as String) as LtXmlComLib20.XmlObjectBase    
        ' This is structured like this to get around compiler limitations
        if eCls = ClsName_NONE then
            Err.Raise 1, "ClassFactory", "Invalid Class (NONE)"
        end if
        
        Select Case (eCls)
        case ClsName_AlbumType
            Set CreateNamedClass = new MusicStoreLib.AlbumType
        case ClsName_Error_
            Set CreateNamedClass = new MusicStoreLib.Error_
        case ClsName_PriceFilter
            Set CreateNamedClass = new MusicStoreLib.PriceFilter
        case ClsName_Result
            Set CreateNamedClass = new MusicStoreLib.Result
        case ClsName_SearchRequest
            Set CreateNamedClass = new MusicStoreLib.SearchRequest
        case ClsName_SearchResponse
            Set CreateNamedClass = new MusicStoreLib.SearchResponse
        case ClsName_TrackType
            Set CreateNamedClass = new MusicStoreLib.TrackType
        case else
            Err.Raise 2, "ClassFactory", "Unknown Class id"
        End Select
        
        Debug.Assert not CreateNamedClass is nothing
        CreateNamedClass.PrivateSetElementName strElementName
    End Function 
    
    
    Public Function CreateClassCollection(byval eCls as MusicStoreLib_Classes, byval strElementName as string, byval strElementNamespaceUri as string, byval iMinOccurs as long, byval iMaxOccurs as long ) as LtXmlComLib20.XmlCollectionBase
        Select Case(eCls)
        case ClsName_NONE
            Err.Raise ERR_INVALID_VALUE, "CreateClassCollection", "Invalid Class (NONE)"
        case ClsName_AlbumTypeCol
            Set CreateClassCollection = new AlbumTypeCol
        case ClsName_TrackTypeCol
            Set CreateClassCollection = new TrackTypeCol
        case else   
            Err.Raise ERR_INVALID_VALUE, "CreateClassCollection", "Unknown Collection Class id"
        End Select
        CreateClassCollection.Init strElementName, strElementNamespaceUri, iMinOccurs, iMaxOccurs
        
    end Function
    
    Public Function CreateEnumCollection(byval eCls as MusicStoreLib_Classes , byval strElementNamespace as string, byval strElementName as string, byval iMinOccurs as long, byval iMaxOccurs as long ) as LtXmlComLib20.XmlCollectionBase
        Select Case(eCls)
        case ClsName_NONE
            Err.Raise ERR_INVALID_VALUE, "CreateEnumCollection", "Invalid Class (NONE)"
        case else
            Err.Raise ERR_INVALID_VALUE, "CreateEnumCollection", "Unknown Collection Class id"
        End Select
        CreateEnumCollection.Init strElementName, strElementNamespace, iMinOccurs, iMaxOccurs
    end Function
    
    Public Property Get EnumConverter as EnumConversions
        Set EnumConverter = mvarEnumConverter
    End Property
    
    
    
    Public Function FromXml( ByVal xmlIn As String, Optional oContext As LtXmlComLib20.XmlSerializationContext = Nothing ) as Object
        Dim oDoc As New MSXML2.DOMDocument60
        oDoc.validateOnParse = False
        oDoc.PreserveWhitespace = True
        If oDoc.loadXML(xmlIn) = False Then
            Err.Raise 103, "XmlObjectBase", "Failed to parse XML" & vbCrLf & oDoc.parseError.reason
        End If
        Set FromXml = FromXmlElement(oDoc.documentElement, oContext)
    End Function
    
    Public Function FromXmlFile( ByVal FileName As String, Optional oContext As LtXmlComLib20.XmlSerializationContext = Nothing ) as Object
        Dim oDoc As New MSXML2.DOMDocument60
        oDoc.validateOnParse = False
        oDoc.PreserveWhitespace = True
        If oDoc.load(FileName) = False Then
            Err.Raise 103, "XmlObjectBase", "Failed to parse XML File " & FileName & vbCrLf & oDoc.parseError.reason
        End If
        Set FromXmlFile = FromXmlElement(oDoc.documentElement, oContext)
    End Function
    
    Public Function FromXmlElement(ByVal oXmlElmParent As MSXML2.IXMLDOMElement, Optional oContext As LtXmlComLib20.XmlSerializationContext = Nothing) As Object
    
        Dim elementName As String
        Dim elementNamespaceUri As String
    
        If oContext Is Nothing Then Set oContext = DefaultXmlSerializationContext
    
        ' Get the type name this is either
        ' from the element i.e. <Parent>... = Parent
        ' or from the type i.e. <Parent xsi:type="someNS:SomeElement">... = SomeElement
        If LtXmlComLib20.XmlObjectBaseHelper.GetElementType(oXmlElmParent) = "" Then
            elementName = oXmlElmParent.baseName
            elementNamespaceUri = oXmlElmParent.NamespaceURI
        Else
            elementName = LtXmlComLib20.XmlObjectBaseHelper.GetElementType(oXmlElmParent)
            elementNamespaceUri = oXmlElmParent.NamespaceURI 
        End If
        
        ' create the appropriate object
        If elementName = "" Then
            Err.Raise 103, "FromXmlElement", "The element to load has no name"
        ElseIf elementName = "AlbumType" And elementNamespaceUri = "" Then
            Set FromXmlElement = New MusicStoreLib.AlbumType
        ElseIf elementName = "Error" And elementNamespaceUri = "" Then
            Set FromXmlElement = New MusicStoreLib.Error_
        ElseIf elementName = "PriceFilter" And elementNamespaceUri = "" Then
            Set FromXmlElement = New MusicStoreLib.PriceFilter
        ElseIf elementName = "Result" And elementNamespaceUri = "" Then
            Set FromXmlElement = New MusicStoreLib.Result
        ElseIf elementName = "SearchRequest" And elementNamespaceUri = "" Then
            Set FromXmlElement = New MusicStoreLib.SearchRequest
        ElseIf elementName = "SearchResponse" And elementNamespaceUri = "" Then
            Set FromXmlElement = New MusicStoreLib.SearchResponse
        ElseIf elementName = "TrackType" And elementNamespaceUri = "" Then
            Set FromXmlElement = New MusicStoreLib.TrackType
        Else
            Err.Raise 103, "FromXmlElement", "Failed load the element " & elementName & ". No appropriate class exists to load the data into. Ensure that the XML document complies with the schema."
        End If
        
        ' load the data into the object
        Dim oBaseClass As LtXmlComLib20.XmlObjectBase
        Set oBaseClass = FromXmlElement
        oBaseClass.FromXmlInt oXmlElmParent, XmlObjectBaseHelper.FindFirstSliblingElement(oXmlElmParent.firstChild), oContext, False
    End Function
                
    ' ##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