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!
...
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...
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...
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...
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...
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 ?
...
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?
...
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.
...
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...
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...
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...
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...
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...
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...
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...
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?
...
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...
I want to access all public variables declared in the class sequentially.
Which is the best way to do it?
...
The title speaks for itself. The language is Java.
...
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...