diff --git a/LINQ/LINQ/APP/Program.vb b/LINQ/LINQ/APP/Program.vb index 29d84c0..62815d4 100644 --- a/LINQ/LINQ/APP/Program.vb +++ b/LINQ/LINQ/APP/Program.vb @@ -1,4 +1,6 @@ -Module Program +Imports Microsoft.VisualBasic.LINQ.Framework.Provider + +Module Program ''' ''' 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 diff --git a/LINQ/LINQ/Framewok/Provider/LinqEntity.vb b/LINQ/LINQ/Framewok/Provider/LinqEntity.vb index 38ca9eb..303d3af 100644 --- a/LINQ/LINQ/Framewok/Provider/LinqEntity.vb +++ b/LINQ/LINQ/Framewok/Provider/LinqEntity.vb @@ -7,7 +7,7 @@ Namespace Framework.Provider ''' ''' - Public Class LinqEntity : Inherits System.Attribute + Public Class LinqEntity : Inherits Attribute Public ReadOnly Property Type As String Public ReadOnly Property RefType As Type diff --git a/LINQ/LINQ/Framewok/Provider/Registry/TypeEntry.vb b/LINQ/LINQ/Framewok/Provider/Registry/TypeEntry.vb index 729a35c..283631a 100644 --- a/LINQ/LINQ/Framewok/Provider/Registry/TypeEntry.vb +++ b/LINQ/LINQ/Framewok/Provider/Registry/TypeEntry.vb @@ -24,13 +24,18 @@ Namespace Framework.Provider ''' Public Property Assembly As String ''' - ''' Full type name for the target LINQ entity type.(目标LINQEntity集合中的类型全称) + ''' Full type name for the target LINQ entity type. Assembly!typeFullName (目标LINQEntity集合中的类型全称) ''' ''' ''' - ''' + ''' Assembly!typeFullName Public Property TypeId As String ''' + ''' 方法的声明位置 + ''' + ''' + Public Property DeclaringType As String + ''' ''' 函数名称 ''' ''' diff --git a/LINQ/LINQ/Framewok/Provider/Registry/TypeRegistry.vb b/LINQ/LINQ/Framewok/Provider/Registry/TypeRegistry.vb index ed2cefd..025f227 100644 --- a/LINQ/LINQ/Framewok/Provider/Registry/TypeRegistry.vb +++ b/LINQ/LINQ/Framewok/Provider/Registry/TypeRegistry.vb @@ -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 + ''' ''' 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