Forum: IronRuby Getting value of IronRuby object's property using reflections

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bc8681d0fcbb7b45710b92493d234551?d=identicon&s=25 Sridharan Sivamurugan (sriyas)
on 2011-04-26 04:37
hi All,

I'm having the ruby class of following structure. I need to gets its
value using reflection that it need to get its value using Property
Descriptor or PropertyInfo collection. I can get this only when I use
the attributes. If I have the object without any attributes its
returning the public methods of the Ruby object.  I need to get the
properties using Property Descriptor, when there is no attributes in the

Please share your Idea this is important for my project.


Class Structure

class Person

    def name

    def name=(n)
        @name = n

    def age

    def age=(a)
        @age = a
Tomas Matousek (Guest)
on 2011-04-26 05:27
(Received via mailing list)
Would this be what you need?

Bc8681d0fcbb7b45710b92493d234551?d=identicon&s=25 Sridharan Sivamurugan (sriyas)
on 2011-04-26 07:06
Hi Tomas,

Yes exactly the same. I need to get those methods as property in C#. Do
you have any idea to achieve this?

959b1c9d700abfc065f5f40bf5a966a2?d=identicon&s=25 James Schementi (jschementi)
on 2011-04-26 17:55
(Received via mailing list)
On Tue, Apr 26, 2011 at 1:06 AM, sridharans sivamurugan
<> wrote:
> Thanks,
> Sri.

Sri, do you actually need to use .NET Reflection APIs? If so, then
your Ruby class would have to inherit from an interface where the
properties you'd want to reflect over are defined. However, I highly
doubt that you absolutely need to use .NET's reflection; you just want
to find the method names available on a Ruby object, correct? Ruby
itself has it's own reflection capabilities built into the language
(Persion.instance_methods), and the DLR hosting API lets you use C# to
access Ruby-defined entities; take a look at the methods on
ScriptEngine.Operations to see what you need to do from C#;
GetMemberNames might be useful to you. You could also write the
reflection code in Ruby and pass the result back to C#:

var personMethods = engine.Execute("Person.instance_methods -
Object.instance_methods", someScope);

Bc8681d0fcbb7b45710b92493d234551?d=identicon&s=25 Sridharan Sivamurugan (sriyas)
on 2011-04-27 11:30
Hi Jimy,

Thanks for the information. But I need to use the .Net reflection API.
I'm trying to do something with the ruby object in my WPF control. So I
can’t use Ruby reflection API, I can get just a Ruby object I need to
manipulate that with the help of Reflection API.

D2a71671c69e5bbc715d7979d69214ec?d=identicon&s=25 Charles Strahan (charles-strahan)
on 2011-04-28 04:26
(Received via mailing list)
Hi Sri,

What is it that you are ultimately trying to accomplish? Are you wanting
bind a control to the Ruby object?


On Wed, Apr 27, 2011 at 4:30 AM, sridharans sivamurugan <
Bc8681d0fcbb7b45710b92493d234551?d=identicon&s=25 Sridharan Sivamurugan (sriyas)
on 2011-05-04 08:17
Hi Charles,

I'm trying to get the value of the Iron Ruby objects using
reflection(using Property Descriptor). This is my ultimate need.

This topic is locked and can not be replied to.