Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
NLua
Commits
10e392a0
Commit
10e392a0
authored
Feb 09, 2019
by
Vinicius Jarina
Browse files
* Fixed GetTableDict
* better performance with GetExtensionMethod.
parent
8e868c0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Extensions/TypeExtensions.cs
View file @
10e392a0
...
...
@@ -90,7 +90,7 @@ namespace NLua.Extensions
return
t
.
GetMethods
(
flags
).
Where
(
m
=>
m
.
Name
==
name
).
ToArray
();
}
public
static
MethodInfo
[]
GetExtensionMethods
(
this
Type
type
,
IEnumerable
<
Assembly
>
assemblies
=
null
)
public
static
MethodInfo
[]
GetExtensionMethods
(
this
Type
type
,
string
name
,
IEnumerable
<
Assembly
>
assemblies
=
null
)
{
var
types
=
new
List
<
Type
>();
...
...
@@ -102,14 +102,12 @@ namespace NLua.Extensions
{
if
(
item
==
type
.
Assembly
)
continue
;
types
.
AddRange
(
item
.
GetTypes
().
Where
(
t
=>
t
.
IsPublic
));
types
.
AddRange
(
item
.
GetTypes
().
Where
(
t
=>
t
.
IsPublic
&&
t
.
IsClass
&&
t
.
IsSealed
&&
t
.
IsAbstract
&&
!
t
.
IsNested
));
}
}
var
query
=
types
.
Where
(
extensionType
=>
extensionType
.
IsSealed
&&
!
extensionType
.
IsGenericType
&&
!
extensionType
.
IsNested
)
.
SelectMany
(
extensionType
=>
extensionType
.
GetMethods
(
BindingFlags
.
Static
|
BindingFlags
.
Public
),
.
SelectMany
(
extensionType
=>
extensionType
.
GetMethods
(
name
,
BindingFlags
.
Static
|
BindingFlags
.
Public
),
(
extensionType
,
method
)
=>
new
{
extensionType
,
method
})
.
Where
(
t
=>
t
.
method
.
IsDefined
(
typeof
(
ExtensionAttribute
),
false
))
.
Where
(
t
=>
...
...
@@ -130,7 +128,7 @@ namespace NLua.Extensions
/// <returns></returns>
public
static
MethodInfo
GetExtensionMethod
(
this
Type
t
,
string
name
,
IEnumerable
<
Assembly
>
assemblies
=
null
)
{
var
mi
=
t
.
GetExtensionMethods
(
assemblies
).
Where
(
method
=>
method
.
Name
==
name
).
ToArray
();
var
mi
=
t
.
GetExtensionMethods
(
name
,
assemblies
).
ToArray
();
if
(
mi
.
Length
==
0
)
return
null
;
return
mi
[
0
];
...
...
src/Lua.cs
View file @
10e392a0
...
...
@@ -901,6 +901,9 @@ namespace NLua
public
Dictionary
<
object
,
object
>
GetTableDict
(
LuaTable
table
)
{
if
(
table
==
null
)
throw
new
ArgumentNullException
(
nameof
(
table
));
var
dict
=
new
Dictionary
<
object
,
object
>();
int
oldTop
=
_luaState
.
GetTop
();
_translator
.
Push
(
_luaState
,
table
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment