在项目中添加新项—类(ctypes.vb)
代码如下
namespace api
public class ctypes
implements istore
dim typelist as sortedlist
dim typelistcsharp as sortedlist
sub new()
typelist = new sortedlist()
typelistcsharp = 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 typelist.containskey(key) then
typelist.add(key, data)
end if
else
if not typelistcsharp.containskey(key) then
typelistcsharp.add(key, data)
end if
end if
end sub
overloads function getdata(byval key as string) as string implements istore.getdata
if typelist.containskey(key) then
return ctype(typelist.item(key), string)
else
return nothing
end if
end function
overloads function getdata(byval index as integer) as string implements istore.getdata
if index < typelist.count then
return ctype(typelist.getbyindex(index), string)
else
return nothing
end if
end function
readonly property count() as integer implements istore.count
get
return typelist.count()
end get
end property
readonly property getkey(byval index as integer) as string implements istore.getkey
get
if index < typelist.count then
return ctype(typelist.getkey(index), string)
else
return ""
end if
end get
end property
overloads function getdatacsharp(byval key as string) as string implements istore.getdatacsharp
if typelistcsharp.containskey(key) then
return ctype(typelistcsharp.item(key), string)
else
return nothing
end if
end function
overloads function getdatacsharp(byval index as integer) as string implements istore.getdatacsharp
if index < typelistcsharp.count then
return ctype(typelistcsharp.getbyindex(index), string)
else
return nothing
end if
end function
end class
end namespace
在项目中添加新项—类(filehandling.vb)
代码如下
imports system.io
imports system.runtime.interopservices
imports microsoft.visualbasic
imports system.threading
namespace api
module filehandling
public const apiseperator = " <@> "
public const apisizeofarray = "sizeofarray"
public const apilong = "long"
public const apiinteger = "integer"
public const apiscope = "^^scope^^ "
public const apipublic = "public "
public const apiprivate = "private "
public const apitype = "<structlayout(layoutkind.sequential)> "
public const apistring = "<marshalas(unmanagedtype.byvaltstr,sizeconst:=sizeofarray)>"
public const apistruct = "<marshalas(unmanagedtype.struct)> byref "
public const apiarray = "<marshalas(unmanagedtype.byvalarray,sizeconst:=sizeofarray)>"
public const apibytevb = "byte"
public const apifloatvb = "double"
public const apistrvb = "string"
public const apianyvb = "any"
public const apistructurevb = "structure"
public const apibyrefvb = "byref"
public const apibyvalvb = "byval"
public const apidllimport = "<<dllimport>>"
public const apidllimportecsharp = "[dllimport(<<dllimport>>)]"
public const apitypecsharp = "[structlayout(layoutkind.sequential)] "
public const apistringcsharp = "[marshalas(unmanagedtype.byvaltstr,sizeconst:=sizeofarray)]"
public const apistructcsharp = "[marshalas(unmanagedtype.struct)] ref "
public const apiarraycsharp = "[marshalas(unmanagedtype.byvalarray,sizeconst:=sizeofarray)]"
public const apistartcsharp = "static extern"
public const apipubliccsharp = "public "
public const apiprivatecsharp = "private "
public const apiintegercsharp = "int "
public const apilongcsharp = "long "
public const apibytecsharp = "byte "
public const apifloatcsharp = "float "
public const apistrcsharp = "string "
public const apistructurecsharp = "struct "
public const apistartscopecsharp = "{" + vbcrlf
public const apiendscopecsharp = "}" + vbcrlf
public const apiendstatementcsharp = ";" + vbcrlf
public const apiseperatoras = " as "
public const apistartconst = "const "
public const apistartcomment = ""
public const apistarttype = "type "
public const apiendtype = "end type"
public const apistartdeclare = "declare "
public const cmb_constants = "constants"
public const cmb_types = "types"
public const cmb_declares = "declares"
public types as ctypes
public constants as cconst
public declares as cdeclare
public frm as new frmviewer()
sub main()
frm.showdialog()
end sub
public sub fillconstants()
dim i as integer
monitor.enter(frm)
frm.lstitem.items.clear()
for i = 0 to constants.count – 1
dim skey as string
skey = constants.getkey(i)
if skey <> "" then frm.lstitem.items.add(constants.getkey(i))
thread.sleep(10)
next
monitor.exit(frm)
end sub
public sub filldeclares()
dim i as integer
monitor.enter(frm)
frm.lstitem.items.clear()
for i = 0 to declares.count – 1
dim skey as string
skey = declares.getkey(i)
if skey <> "" then frm.lstitem.items.add(declares.getkey(i))
thread.sleep(1)
next
monitor.exit(frm)
end sub
public sub filltypes()
dim i as integer
monitor.enter(frm)
frm.lstitem.items.clear()
for i = 0 to types.count – 1
dim skey as string
skey = types.getkey(i)
if skey <> "" then frm.lstitem.items.add(types.getkey(i))
thread.sleep(1)
next
monitor.exit(frm)
end sub
end module
end namespace
在代码中添加新项–类(istore.vb)
代码如下
namespace api
public interface istore
sub add(byval key as string, byval data as string, optional byval bcsharp as boolean = false)
readonly property count() as integer
overloads function getdata(byval index as integer) as string
overloads function getdata(byval key as string) as string
readonly property getkey(byval index as integer) as string
overloads function getdatacsharp(byval key as string) as string
overloads function getdatacsharp(byval index as integer) as string
end interface
end namespace
