1

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...
halfer
  • 19,824
  • 17
  • 99
  • 186
Ted
  • 19,727
  • 35
  • 96
  • 154

1 Answers1

0

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
SwDevMan81
  • 48,814
  • 22
  • 151
  • 184
  • Thx! I havent played around with LUA since I wrote the post, but if I eventually do, I'll try your thing =) – Ted Aug 24 '11 at 10:54