reflection

Given a type instance, how to get generic type name in C#?

Given a generic type, including List<string> Nullable<Int32> how do i get a generic name for C#? var t = typeof(Nullable<DateTime>); var s = t.GetGenericTypeDefinition().Name + "<" + t.GetGenericArguments()[0].Name + ">"; This yields "Nullable`1<DateTime>" , but i need "Nullable<DateTime>" . ...

Mimic property/list changes on an object on another object

I need to mimic changes (property/list) changes on an object and then apply it to another object to keep the structure/property the same. In essence it's like cloning etc. the biz rules require certain properties to not be applied to the other object, so I can't just clone the object otherwise this would be easy. I've already walked th...

Is there a way to return a method parameter names in ruby

Is it possible to get the parameter names of a method ? Example with: def method_called(arg1, arg2) puts my_method.inspect end I would like to know what method (my_method) should I call to get the following output: ["arg1", "arg2"] ...

What are the suggested alternatives for Class<T>.isAssignableFrom(Class<?> cls)?

Currently I am doing the profiling to a piece of code. During the profiling, I discovered that this very method call, Class<T>.isAssignableFrom(Class<?> cls) takes up to quite amount of the entire time. Because this is a method from reflection, it takes a lot of time compared to normal keywords or method calls. I am wondering if the...

How visual studio intellisense recognize functions and properties in classes even though there is no reflection in C++ ?

I want to list properties and functions present in c++ classes. Is that functionality already implemented in any library ? Does visual studio intellisense use any library ? Is that library available publicly from Microsoft? ...

listing the functions of a web service

hi, I wanted to make an application that will take either the path of the dll or Webservice and list me all the functions present in that dll. I accomplished the listing of the function using this but I am not able to list the functions of the Webservices. Using Assembly.GetMembers() it's listing the Function Name with the Parame...

What are the interets of synthetic methods?

Problem One friend suggested an interesting problem. Given the following code: public class OuterClass { private String message = "Hello World"; private class InnerClass { private String getMessage() { return message; } } } From an external class, how may I print the message variable content...

Does Powershell have an "eval" equivalent? Is there a better way to see a list of properties and values?

I'm doing a bit of Powershell scripting ( for the first time ) to look at some stuff in a Sharepoint site and what I would like to be able to do is to go through a list of properties of an object and just output their values in a "property-name = value" kind of format. Now I can find the list of elements using this: $myObject | get-mem...

how iterate over class members java (app-engine)

Hello, I am using the java version of the google app engine. I would like to create a function that can receive as parameters many types of objects. I would like to print out the members of the object. Each objects may be different and the function must work for all objects. Do I have to use reflection - if so, what kind of code do I ne...

Adding metadata attributes to MySQL table

I would like to add custom attributes to a MySQL table which I can read via php. These attributes are not to interfere with the table itself - they are primarily accessed by php code during code generation time and these attributes HAVE to reside in the DB itself. Something similar in concept to .NET reflection. Does MySQL support any...

invoking a static method using reflections

hi, in my project i want to invoke the main method which is static . I got the object of type Class but i am not able to create an instance of that class and also not able to invoke the static method "main".Help ...

Unable to instantiate a class using classloader

hi, i load a class using ClassLoader but i am not able to create an object of that class.Here is the code.What is the problem?Help Cloader = new URLClassLoader(new URL[] {new File(binfolderurl).toURI().toURL()},ClassLoader.getSystemClassLoader); Thread.currentThread().setContextClassLoader(Cloader); Class clss = Cloader.loadClass("...

What's the difference between calling MyClass.class and MyClass.getClass()

MyClass.class and MyClass.getClass() both seem to return a java.lang.Class. Is there a subtle distinction or can they be used interchangeably? Also, is MyClass.class a public property of the superclass Class class? (I know this exists but can't seem to find any mention of it in the javadocs) ...

Invoking WCF functions using Reflection

I am pretty new to WCF applications. I have a WCF application that is using NetTcpBinding. I wanted to invoke the functions in WCF service using the System.Reflection's Methodbase Invoke method. I mean I wanted to Dynamically call the Function by passing the String as the Function name. Reflection works great for Web Service or a Windows...

Listing functions of an unmanaged DLL at runtime in c#

Hi, Is it possible to obtain a list of functions declared in an unmanaged DLL? I want to create this list in a c# program. Using dumpbin or System.Reflection.Assembly is not possible. Thanks ...

What is the general feeling about reflection extensions in std::type_info?

I've noticed that reflection is one feature that developers from other languages find very lacking in c++. For certain applications I can really see why! It is so much easier to write things like an IDE's auto-complete if you had reflection. And certainly serialization APIs would be a world easier if we had it. On the other side, one of...

Setting specified flags before serializing objects

We have a schema that we serialize and deserialize into an object hierarchy. Some elements are optional in the schema. The xsd tool creates a cs file that inserts a property for each optional element. This property ends in "Specified", i.e. nameSpecified tells the serializer and deserializer to include the optional "name" element when pr...

Using reflection to change static final File.separatorChar for unit testing?

Specifically, I'm trying to create a unit test for a method which requires uses File.separatorChar to build paths on windows and unix. The code must run on both platforms, and yet I get errors with JUnit when I attempt to change this static final field. Anyone have any idea what's going on? Field field = java.io.File.class.getDeclaredF...

Constructor invocation returned null: what to do?

I have code which looks like: private static DirectiveNode CreateInstance(Type nodeType, DirectiveInfo info) { var ctor = nodeType.GetConstructor(new[] { typeof(DirectiveInfo) }); if(ctor == null) { throw new MissingMethodException(nodeType.FullName, "ctor"); } var node = ctor.Invoke(new[] { info }) as Directiv...

Accessing object properties from string representations

In actionscript an object's property can be accesses in this way: object["propertyname"] Is something like this possible in c#, without using reflection? ...