Imports DevExpress.ExpressApp.Model
Imports DevExpress.ExpressApp.Model.Core
Imports DevExpress.ExpressApp.Model.NodeGenerators
Imports SISBusiness.Module.Dennis.Linq

Public Class ModelListViewLinqNodesGeneratorUpdater
    Inherits ModelNodesGeneratorUpdater(Of ModelViewsNodesGenerator)
    Public Overrides Sub UpdateNode(ByVal node As ModelNode)
        For Each classInfo As IModelClass In node.Application.BOModel
            If classInfo.TypeInfo.IsPersistent Then
                If (Not String.IsNullOrEmpty(classInfo.Name)) Then
                    For Each method As String In LinqCollectionSourceHelper.GetXPQueryMethods(classInfo.TypeInfo.Type)
                        Dim id As String = String.Format("{0}_{1}{2}", ModelListViewNodesGenerator.GetListViewId(classInfo.TypeInfo.Type), method, LinqCollectionSource.DefaultSuffix)
                        Dim listViewInfo As IModelListView = node.Application.Views.GetNode(id)
                        If listViewInfo Is Nothing Then
                            listViewInfo = node.AddNode(Of IModelListView)(id)
                        End If
                        listViewInfo.ModelClass = classInfo
                        If TryCast(listViewInfo, IModelListViewLinq) IsNot Nothing Then
                            CType(listViewInfo, IModelListViewLinq).XPQueryMethod = method
                        End If
                    Next method
                End If
            End If
        Next classInfo
    End Sub
End Class
