reflection

How to determine by reflection if a Method returns 'void'

Hi, I have a java.lang.reflect.Method object and I would like to know if it's return type is void. I've checked the Javadocs and there is a getReturnType() method that returns a Class object. The thing is that they don't say what would be the return type if the method is void. Thanks! ...

List<> of dynamicly created structure

In C# I want to create a list based on a dynamic value type, e.g.: void Function1() { TypeBuilder tb = .... // tb is a value type ... Type myType = tb.CreateType(); List<myType> myTable = new List<myType>(); } void Function2(Type myType) { List<myType> myTable = new List<myType>(); } This won't comple because List<> want...

SQL <-> Class (De)Serializer?

Today I learned this JavaScriptSerializer ser = new JavaScriptSerializer(); Foo foo = ser.Deserialize<Foo>(jsonSz); I had to match the class with the json I was pulling from a remote site. It saved me much time that I could just write the class and not worry about processing the data and putting them into the class. I also didn't need...

How to reflect on method with out params?

I am trying to get a MethodInfo object for a method on a type with an out param in its signature. Something to the effect of this: MethodInfo tryParse = typeof(T).GetMethod( "TryParse", BindingFlags.Public|BindingFlags.Static, null, new Type[] { typeof(string), typeof(T) }, null); But the problem is, it doesn't fin...

Reflection and late binding in Silverlight

I want to be able to load items in System.Windows.Controls using late binding. I can do it with dlls that i can load remotely like this: private void Button_Click(object sender, RoutedEventArgs e) { panel1.Children.Clear(); WebClient c = new WebClient(); c.OpenReadCompleted += new OpenReadCompletedEven...

Getting the superclass(es) of a Python class

class p1(object): pass class p2(p1): pass So p2 is the subclass of p1. Is there a way to find out programmatically that p1 is [one of] the superclass[es] of p2 ? ...

How to call a generic method through reflection

Hi, is it possible to call with reflection a method with "explict type argument" <S> definition e.g. oObject.Cast<S>() ? where is: IList <P> oObject = new List <P>(); I tried with oObject.getType().InvokeMember( "Cast", BindingFlags.InvokeMethod, null, oObject, null) but it does not work, does anyone know why? ...

.NET reflection : How do I invoke a method via reflection that returns array of objects?

Had a quick question.. Googled but nothing worthwhile found.. I have a simple type like shown below. public class DummyClass { public string[] Greetings() { return new string[] { "Welcome", "Hello" }; } } How can I invoke the "Greetings" method via reflection? Note the method returns array of strings. ...

JavaScript: invoke function or call a property via reflection

Is there a way to call a function (or a property) on an object via reflection, in JavaScript? Lets say that during run-time, my code has already determined that objectFoo indeed has a property called 'bar'. Now that my code knows that, the next thing I want to do is invoke that. Normally i would do this: var x = objectFoo.bar. B...

How to call extension method "ElementAt"of List<T> with reflection ?

Hi all, I have problem that after creating object "oListType01" of type List < MyClass01 > and after assigning it to the another objet "oObjectType " of type "object" I can not access any more function "ElementAt(1)". I tried by using reflection but I am always getting exception(parameter conflict) in "Invoke" method. Does anyone knows...

ASP.net mvc, generic/dynamic controllers and Type.GetType: how can I keep my URLs pretty?

Using information from some of the questions here on generic views, I have created an MVC app that reads .dlls from its own /bin directory and builds the UI on the fly. InputBuilder partial views helped a lot. I also made a ControllerFactory, after the advice from here and elsewhere. My problem is, while everything is working OK and ref...

Java Reflect 2 objects

Hi i got the code below : ModuleA.Student student 1 = null; ModuleB.Student student 2 = null; student2 = retrieveStudentFacade().findStudentbyName("John"); student1 = StudentSessionEJBBean.convert(student2,ModuleA.Student.Class); The problem now student1.getId(); return null but supposed to return me a value. Below is the converter m...

What is the best way to control the order in which reflected property values are returned?

I have one class that inherits another. I want to use reflection to cycle through the properties and write the values to a file. No problem. Except that I want to control the order in which the properties write out. Is there a clean way to do this? Right now, problem 1 is that the properties in the the subclass write out and THEN the p...

Why does this MSDN example on Reflection fail?

I coppied and pasted this example, and it seems to fail. Why is MethodBase null? http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo.isout.aspx edit: here is a link to my code: http://img689.imageshack.us/img689/3453/94123952.png Let me know where my copy & paste is wrong. here is the code for those that cant vi...

Using reflection in C# to get properties of a nested object.

Given the following objects: public class Customer { public String Name { get; set; } public String Address { get; set; } } public class Invoice { public String ID { get; set; } public DateTime Date { get; set; } public Customer BillTo { get; set; } } I'd like to use reflection to go through the Invoice to get the...

Reflection to get the Delegate Information

By executing the following i can get the information about methods Type t=typeof(someType); MemberInfo[] mInfo = t.GetMethods(); how to get information about delegates declared inside a type? ...

Detecting if a method is declared in an interface in Java

Help me make this method more solid: /** * Check if the method is declared in the interface. * Assumes the method was obtained from a concrete class that * implements the interface, and return true if the method overrides * a method from the interface. */ public static boolean isDeclaredInInterface(Method method, Class<?> i...

how to access all public variables in the class sequentially?

I want to access all public variables declared in the class sequentially. Which is the best way to do it? ...

Is there a way to get all the classes that implement a certain method?

The title speaks for itself. The language is Java. ...

PHP - get_class_methods() Problem

I've this sample code: class A { public function A_A() { /* ... */ } public function A_B() { /* ... */ } } class B extends A { public function B_A() { /* ... */ } public function B_B() { /* ... */ } public function B_C() { return get_class_methods($this); } } $a = new A(); $b = new B(); Doing this: echo '<pre>'; print_r...