答案:在项目中添加新项---类(ParseAPI.vb)
代码如下
Imports System.IO
Namespace API
Public Class ParseAPI
Dim sOldAPI As String
Dim sNewAPI As String
Dim pFile As String
Dim pReader As StreamReader
Public Sub New(ByVal sFile As String)
If File.Exists(sFile) Then
pFile = sFile
Else
pFile = ""
End If
End Sub
Public Sub GetTypeInfo()
Dim sReturn As String
Dim sCSharp As String
Dim sCSharpInput As String
Dim sKey As String
Dim bStart As Boolean = False
Dim bTypeStatement As Boolean = False
If pFile <> "" Then
If Not File.Exists(pFile) Then
Types = Nothing
Return
End If
Dim sr As StreamReader = File.OpenText(pFile)
Dim input As String
input = sr.ReadLine()
While Not input Is Nothing
If bStart = False And InStr(1, input, APISTARTTYPE) <> 0 Then
If Not input.StartsWith("'") Then
If Split(input, " ").Length() <= 2 Then
sKey = Split(input, " ")(1).ToString()
sCSharpInput = input
input = input.Replace(APISTARTTYPE, APITYPE + APISCOPE + " Structure ").ToString()
sCSharpInput = sCSharpInput.Replace(APISTARTTYPE, APITYPECSHARP + vbCrLf + APISCOPE + " " + APISTRUCTURECSHARP).ToString() + APISTARTSCOPECSHARP
bStart = True
bTypeStatement = True
End If
End If
End If
If bStart Then
If InStr(1, input, APIENDTYPE) <> 0 Then
sCSharpInput = input
input = input.Replace(APIENDTYPE, "End Structure").ToString()
sCSharpInput = sCSharpInput.Replace(APIENDTYPE, APIENDSCOPECSHARP).ToString()
sReturn += input & vbCrLf
sReturn = sReturn.Replace(APILONG, APIINTEGER)
sCSharp += sCSharpInput & vbCrLf
sCSharp = sCSharp.Replace(APILONG, APIINTEGER)
sCSharp = ChangeDeclartion(sCSharp)
Types.Add(sKey, sReturn)
Types.Add(sKey, sCSharp, True)
 
上一个:c#根据一个传入的字符串得到需要使用的类
下一个:在.NET运行时了解类型信息(3) Paul_Ni(原作)