registry can gets the handle correctly!

master
謝桂綱 10 years ago
parent 6a68ecdf04
commit 17e6c2e6dc

@ -1,4 +1,6 @@
Module Program
Imports Microsoft.VisualBasic.LINQ.Framework.Provider
Module Program
''' <summary>
''' DO_NOTHING
@ -9,6 +11,10 @@
Dim s As String = "From var As Type In ""$source->parallel"" Let x = var -> aa(d,""g ++ "") Let y as string = var -> aa(d,""g ++ "") where x -> test2(test3(xx),var) is true Let x = var -> aa(d,""g ++ "") Let x = var -> aa(d,""g ++ "") Let x = var -> aa(d,""g ++ "") select new varType(var,x), x+3"
Dim expr = LINQ.Statements.LINQStatement.TryParse(s)
Dim r As TypeRegistry = TypeRegistry.LoadDefault
Dim h = r.GetHandle("typedef")
Dim c = h("E:\Microsoft.VisualBasic.Parallel\trunk\LINQ\LINQ\bin\Debug\Settings\LinqRegistry.xml")
Return GetType(CLI).RunCLI(App.CommandLine, AddressOf __exeEmpty)
End Function

@ -7,7 +7,7 @@ Namespace Framework.Provider
''' </summary>
''' <remarks></remarks>
<AttributeUsage(AttributeTargets.Method, AllowMultiple:=False, Inherited:=True)>
Public Class LinqEntity : Inherits System.Attribute
Public Class LinqEntity : Inherits Attribute
Public ReadOnly Property Type As String
Public ReadOnly Property RefType As Type

@ -24,13 +24,18 @@ Namespace Framework.Provider
''' <remarks></remarks>
<Xml.Serialization.XmlAttribute> Public Property Assembly As String
''' <summary>
''' Full type name for the target LINQ entity type.(LINQEntity)
''' Full type name for the target LINQ entity type. Assembly!typeFullName (LINQEntity)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
''' <remarks>Assembly!typeFullName</remarks>
<Xml.Serialization.XmlAttribute> Public Property TypeId As String
''' <summary>
''' <see cref="Func"/>
''' </summary>
''' <returns></returns>
<Xml.Serialization.XmlAttribute> Public Property DeclaringType As String
''' <summary>
'''
''' </summary>
''' <returns></returns>

@ -43,6 +43,25 @@ Namespace Framework.Provider
End If
End Function
Public Function GetHandle(name As String) As GetLinqResource
Dim entry As TypeEntry = Find(name)
Dim assm As Assembly = entry.LoadAssembly
Dim type = assm.GetType(entry.DeclaringType)
Dim method As MethodInfo = type.GetMethod(entry.Func, types:={GetType(String)})
Dim [delegate] As New __delegateProvider With {.method = method}
Dim handle As GetLinqResource = AddressOf [delegate].GetLinqResource
Return handle
End Function
Private Class __delegateProvider
Public method As MethodInfo
Public Function GetLinqResource(uri As String) As IEnumerable
Dim value As Object = method.Invoke(Nothing, {uri})
Return DirectCast(value, IEnumerable)
End Function
End Class
''' <summary>
''' Return a registry item in the table using its specific name property.
''' ()
@ -77,12 +96,10 @@ Namespace Framework.Provider
For Each x As TypeEntry In LQuery.MatrixToList 'Update exists registry item or insrt new item into the table
Dim exists As TypeEntry = Find(x.name) '
If exists Is Nothing Then
Call Me.typeDefs.Add(x) 'Insert new record.()
Else 'Update exists data.()
exists.Assembly = x.Assembly
exists.TypeId = x.TypeId
If Not exists Is Nothing Then
Call _typeHash.Remove(x.name)
End If
Call _typeHash.Add(x.name, x) 'Insert new record.()
Next
Return True
End Function
@ -100,7 +117,8 @@ Namespace Framework.Provider
.Func = x.x.Name,
.Assembly = path,
.name = x.attr.Type,
.TypeId = x.attr.RefType.FullName
.TypeId = FileIO.FileSystem.GetFileInfo(x.attr.RefType.Assembly.Location).Name & "!" & x.attr.RefType.FullName,
.DeclaringType = x.x.DeclaringType.FullName
})
Return result
End Function

Loading…
Cancel
Save