lib/caricature/clr/descriptor.rb in caricature-0.6.3 vs lib/caricature/clr/descriptor.rb in caricature-0.7.0
- old
+ new
@@ -24,10 +24,20 @@
# gets the property name from the +PropertyInfo+
# when the property is an indexer it will return +[]+
def property_name_from(property_info)
return property_info.name.underscore if property_info.get_index_parameters.empty?
"__getitem__"
+ end
+
+ # the binding flags for instance members of a CLR type
+ def instance_flags
+ System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.instance
+ end
+
+ # the binding flags for class members of a CLR type
+ def class_flags
+ System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.static
end
end
# describes clr interfaces.
@@ -60,21 +70,21 @@
# collects all the instance members of the provided CLR class type
def initialize_instance_members_for(klass)
clr_type = klass.to_clr_type
- methods = Workarounds::ReflectionHelper.get_instance_methods(clr_type)
- properties = Workarounds::ReflectionHelper.get_instance_properties(clr_type)
+ methods = clr_type.get_methods(instance_flags)
+ properties = clr_type.get_properties(instance_flags)
@instance_members = collect_members_from methods, properties
end
# collects all the static members of the provided CLR class type
def initialize_class_members_for(klass)
clr_type = klass.to_clr_type
- methods = Workarounds::ReflectionHelper.get_class_methods(clr_type)
- properties = Workarounds::ReflectionHelper.get_class_properties(clr_type)
+ methods = clr_type.get_methods(class_flags)
+ properties = clr_type.get_properties(class_flags)
@class_members = collect_members_from methods, properties, false
end
end
\ No newline at end of file