sridharans sivamurugan
2011-Apr-26 02:37 UTC
[Ironruby-core] Getting value of IronRuby object''s property using reflections
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 object. Please share your Idea this is important for my project. Thanks. Sri Class Structure class Person def name @name end def name=(n) @name = n end def age @age end def age=(a) @age = a end end -- Posted via http://www.ruby-forum.com/.
Tomas Matousek
2011-Apr-26 03:14 UTC
[Ironruby-core] Getting value of IronRuby object''s property using reflections
Would this be what you need? http://ironruby.codeplex.com/workitem/4920 Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of sridharans sivamurugan Sent: Monday, April 25, 2011 7:38 PM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Getting value of IronRuby object''s property using reflections 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 object. Please share your Idea this is important for my project. Thanks. Sri Class Structure class Person def name @name end def name=(n) @name = n end def age @age end def age=(a) @age = a end end -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
sridharans sivamurugan
2011-Apr-26 05:06 UTC
[Ironruby-core] Getting value of IronRuby object''s property using reflections
Tomas Matousek wrote in post #995011:> Would this be what you need? > http://ironruby.codeplex.com/workitem/4920 > > TomasHi Tomas, Yes exactly the same. I need to get those methods as property in C#. Do you have any idea to achieve this? Thanks, Sri. -- Posted via http://www.ruby-forum.com/.
Jimmy Schementi
2011-Apr-26 15:38 UTC
[Ironruby-core] Getting value of IronRuby object''s property using reflections
On Tue, Apr 26, 2011 at 1:06 AM, sridharans sivamurugan <lists at ruby-forum.com> wrote:> Tomas Matousek wrote in post #995011: >> Would this be what you need? >> http://ironruby.codeplex.com/workitem/4920 >> >> Tomas > > Hi Tomas, > > Yes exactly the same. I need to get those methods as property in C#. Do > you have any idea to achieve this? > > 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); ~Jimmy
sridharans sivamurugan
2011-Apr-27 09:30 UTC
[Ironruby-core] Getting value of IronRuby object''s property using reflections
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. -Sri. -- Posted via http://www.ruby-forum.com/.
Charles Strahan
2011-Apr-28 01:02 UTC
[Ironruby-core] Getting value of IronRuby object''s property using reflections
Hi Sri, What is it that you are ultimately trying to accomplish? Are you wanting to bind a control to the Ruby object? -Charles On Wed, Apr 27, 2011 at 4:30 AM, sridharans sivamurugan < lists at ruby-forum.com> wrote:> 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. > > -Sri. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20110427/c131e6f6/attachment.html>
sridharans sivamurugan
2011-May-04 06:17 UTC
[Ironruby-core] Getting value of IronRuby object''s property using reflections
Hi Charles, I''m trying to get the value of the Iron Ruby objects using reflection(using Property Descriptor). This is my ultimate need. -Sri. -- Posted via http://www.ruby-forum.com/.