Imports System.IO Imports EgtUILib ''' ''' Class that create the association Name/IniPath for the machine ''' Public Class Machine Private m_sName As String Public ReadOnly Property Name As String Get Return m_sName End Get End Property Private m_DirPath As String Public ReadOnly Property DirPath As String Get Return m_DirPath End Get End Property Private m_IniPath As String Public ReadOnly Property IniPath As String Get Return m_IniPath End Get End Property Sub New(sDirPath As String, sIniPath As String) If Not String.IsNullOrWhiteSpace(sDirPath) Then m_sName = Path.GetFileName(sDirPath) m_DirPath = sDirPath m_IniPath = sIniPath Else m_sName = String.Empty m_DirPath = String.Empty m_IniPath = String.Empty End If End Sub Public Shared Function MachineListInit(sMachinesRootDir As String, MachineList As IList(Of Machine)) As Boolean ' Recupero le macchine definite Dim sMachNames As String() = Nothing Dim sMachDirs As String() = Nothing EgtGetMachines(sMachNames, sMachDirs) ' Verifico esista almeno una macchina If IsNothing(sMachNames) OrElse sMachNames.Count = 0 Then Return False ' Carico i dati delle macchine Dim MyMachineList As New List(Of Machine) For i As Integer = 0 To sMachNames.Count - 1 Dim PathIni As String = sMachDirs(i) & "\" & sMachNames(i) & ".ini" If File.Exists(PathIni) Then MyMachineList.Add(New Machine(sMachDirs(i), PathIni)) End If Next ' Ordino alfabeticamente la lista delle macchine MyMachineList = MyMachineList.OrderBy(Function(x) x.Name).ToList() ' Assegno i valori ordinati For Each Item In MyMachineList MachineList.Add(Item) Next Return True End Function Public Shared Function SearchMachine(sName As String, MachineList As IList(Of Machine), ByRef FoundMachine As Machine) As Boolean For Each Machine In MachineList If String.Compare( Machine.Name, sName, True) = 0 Then FoundMachine = Machine Return True End If Next FoundMachine = Nothing Return False End Function Public Shared Function SearchMachineIni(sName As String, MachineList As IList(Of Machine), ByRef FoundedIni As String) As Boolean For Each Machine In MachineList If Machine.Name = sName Then FoundedIni = Machine.IniPath Return True End If Next FoundedIni = String.Empty Return False End Function Public Shared Function ExistsMachine(sName As String, MachineList As IList(Of Machine)) As Boolean For Each Machine In MachineList If Machine.Name = sName Then Return True End If Next Return False End Function End Class