Public Sub Add(ByVal ConnectionInfo As Item) If ConnectionInfo Is Nothing Then Exit Sub If m_Count > 0 Then If Not Me.ConnectionInfo(ConnectionInfo.ID) Is Nothing Then MsgBox(ID.ToString & "已存在") Exit Sub End If End If ReDim Preserve Me.Items(m_Count) Me.Items(m_Count) = ConnectionInfo m_Count += 1 End Sub '取指定ID的配置信息 Public ReadOnly Property ConnectionInfo(ByVal ID As Integer) As Item Get Dim mItem As Item Dim i As Integer For i = 0 To m_Count - 1 If Me.Items(i).ID = ID Then mItem = Me.Items(ID) Exit For End If Next Return mItem End Get End Property '序列化并保存到指定文件 Public Sub SaveXmlFile(ByVal FileName As String) If Me Is Nothing Then Exit Sub Dim XmlWriter As New System.IO.StreamWriter(FileName, False) XmlWriter.Write(SerializeClass.GetXML(Me)) XmlWriter.Close() End Sub '从指定文件读取反序列化转为对象 Public Function LoadXmlFile(ByVal FileName As String) As Config Dim XmlReader As New System.IO.StreamReader(FileName, System.Text.Encoding.Default) |