当前位置:编程学习 > C#/ASP.NET >>

用vb.net开发api viewer(3)

答案:在项目文件中添加新项-类(CConst.vb)
代码如下:
Namespace API
    Public Class CConst
        Implements IStore
        Dim ConstList As SortedList
        Dim ConstListCSharp As SortedList
        Sub New()
            ConstList = New SortedList()
            ConstListCSharp = New SortedList()
        End Sub
        Sub Add(ByVal Key As String, ByVal Data As String, Optional ByVal bCSharp As Boolean = False) Implements IStore.Add
            If Not bCSharp Then
                If Not ConstList.ContainsKey(Key) Then
                    ConstList.Add(Key, Data)
                End If
            Else
                If Not ConstListCSharp.ContainsKey(Key) Then
                    ConstListCSharp.Add(Key, Data)
                End If
            End If
        End Sub
        Overloads Function GetData(ByVal Key As String) As String Implements IStore.GetData
            If ConstList.ContainsKey(Key) Then
                Return CType(ConstList.Item(Key), String)
            Else
                Return Nothing
            End If
        End Function
        Overloads Function GetData(ByVal index As Integer) As String Implements IStore.GetData
            Return CType(ConstList.GetByIndex(index), String)
        End Function
        ReadOnly Property Count() As Integer Implements IStore.Count
            Get
                Return ConstList.Count()
            End Get
        End Property
        ReadOnly Property GetKey(ByVal index As Integer) As String Implements IStore.GetKey
            Get
                If index < ConstList.Count Then
                    Return CType(ConstList.GetKey(index), String)
                Else
                    Return ""
                End If
            End Get
        End Property
        Overloads Function GetDataCSharp(ByVal Key As String) As String Implements IStore.GetDataCSharp
            If ConstListCSharp.ContainsKey(Key) Then
                Return CType(ConstListCSharp.Item(Key), String)
            Else
                Return Nothing
            End If
        End Function
        Overloads Function GetDataCSharp(ByVal index As Integer) As String Implements IStore.GetDataCSharp
            If index < ConstListCSharp.Count Then
                Return CType(ConstListCSharp.GetByIndex(index), String)
            Else
                Return Nothing
            End If
        End Function
    End Class
End Namespace
在项目中添加新项---类(CDeclare.vb)
代码如下
Namespace API
    Public Class CDeclare
        Implements IStore
        Dim DeclareList As SortedList
        Dim DeclareListCSharp As SortedList
        Sub New()
            DeclareList = New SortedList()
            DeclareListCSharp = New SortedList()
        End Sub
        Sub Add(ByVal Key As String, ByVal Data As String, Optional ByVal bCSharp As Boolean = False) Implements IStore.Add
            If Not bCSharp Then
                If Not DeclareList.ContainsKey(Key) Then
                    DeclareList.Add(Key, Data)
                End If
            Else
                If Not DeclareListCSharp.ContainsKey(Key) Then
                    DeclareListCSharp.Add(Key, Data)
                End If
            End If
   

上一个:Windows消息类。非常的有用。国外的,我特意贴出来。
下一个:用vb.net开发api viewer(4)

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,