Lua / LuaInterface - How to access C# Attributes?
I have been looking for a way so that in Lua script I can access custom attributes for a class.
I know that I can implement a normal C# method and in that method access the Attribute using normal Reflection and then do a registerMethod on the Lua-object.
But in this case I don't want to write a C#-method but just write a normal string with the Lua-code and there access the Attribute.
My question is how to do it? Is the right way to do something like
require 'CLRPackage'
import "System.Reflection"
开发者_开发知识库
typeOfObject = type(myClrObject)
typeOfObject.GetCustomAttribute(...)
-- something more...
I know this is a bit old, but I was able to get this to work with something like this:
> require 'CLRPackage'
> import "System"
> int_type = Type.GetType("System.Int32")
> attrs = int_type:GetCustomAttributes(true)
> for i=0,attrs.Length-1 do Console.WriteLine(attrs:GetValue(i)) end
System.SerializableAttribute
System.Runtime.InteropServices.ComVisibleAttribute
精彩评论