[Ironruby-core] Getting property list from both Ruby and .Net objects
lists at ruby-forum.com
Mon Sep 24 08:21:25 UTC 2012
I need some tools to get property names of both Ruby objects and .Net
objects. First I thought that there'll be no problem with it. I tried to
do it like:
But it turned out that when "obj" is a .Net object
obj.instance_variables returns nothing. Well, it returns an array but
array is empty.
foo = Foo.new
foo.NetVal1 = "Hello"
foo.NetVal2 = 100
puts foo.class # => FooModule::Foo
puts foo.NetVal1 # => Hello
puts doo.NetVal2 # => 100
puts foo.instance_variables # => #it's blank here
puts foo.instance_variables.class # => Array
Well, then I thought that I can use reflection to get property list for
array = Array.new
obj.GetType().GetProperties.each do |prop|
But it didn't work for a ruby object. I tried to somehow find out
weather object is from ruby or .Net and depending on it parse objects,
but I couldn't think of any working solution.
So my question is:
Give me a hint on how I can parse both ruby and .net objects using one
Thanks in advance,
Posted via http://www.ruby-forum.com/.
More information about the Ironruby-core