I am working on code generation and ran into a snag with generics. Here is a "simplified" version of what is causing me issues.
Dictionary<string, DateTime> dictionary = new Dictionary<string, DateTime>();
string text = dictionary.GetType().FullName;
MessageBox.Show(text);
With the above code snippet the value for "text" is as follows...
hello
I want all the Method-ClassName from namespace
like i have system.windows.Forms
wehen in visual studio we rigt system.windows.Forms. it will suggest box of all the related method,class,enum extra
i need to fetch the same ,how can i do that in C#
Thanks
...
I'd like to show a list of all used assemblies on a dedicated web page inside a ASP.NET web application for debugging and maintainance purposes (there are many instances of this web application on many different servers). The assemblies could be called from the bin folder or from the GAC. There are some written by myself, but also third-...
This is really stumping me today. I'm sure its not that hard, but I have a System.Reflection.PropertyInfo object. I want to set its value based on the result of a database lookup (think ORM, mapping a column back to a property).
My problem is if the DB returned value is DBNull, I just want to set the property value to its default, the ...
I've some classes defined in a dll file. These are in the form of com api.
I'm trying to create an object of one of the class dynamically and than setting some property of that object.
When I set the property manually, it works, but when I try to invoke the same using reflection it gives the error that
Object does not match target ty...
I'm loading an assembly at runtime and the question that arises everytime I call the code is that should I be checking if that particular assembly has loaded already? or does .Net take care of this and one assembly (same version) can only be loaded once? The basic question here is do i have to iterate through a list of loaded assemblies ...
I have a CLI/C++ interface that I want to examine via .NET Reflection. Here's the function signature in the source code:
class ClassA;
template<typename _Type> class ClassTempA;
public interface class Test : BaseFunc {
public:
ClassTempA<int>& SomeFunc2(ClassA inst) = 0;
};
Here's what the function looks like when examined in .N...
I have a generic Callback object which provides a (primitive) callback capability for Java, in the absence of closures. The Callback object contains a Method, and returns the parameter and return types for the method via a couple of accessor methods that just delegate to the equivalent methods in Method.
I am trying to validate that a ...
When attempting to use Joshua Bloch's "Builder Pattern" [Item 2 in Effective Java Second Edition] with reflection [object = constructors[index].newInstance(constructorParameterValues);] the following exception occurs:
java.lang.IllegalAccessException: Class info.soaj.core.util.SjUtilReflection can not access a member of class info.soaj....
In C#, I'm marking some classes' properties with attributes and I'm using reflection to find these properties in order to perform gets and sets on them. I've found, however, that getting/setting with reflection in this manner is approximately 10x as slow as POCO gets/sets. Besides dropping the fundamental scenario described above to use ...
I am wondering if there are any additional optimizations I can implement to improve the speed of reflective invocations in Java. Not that the performance is prohibitive, but I get the willies when thinking about some piece of code in a library I am writing being implemented in a tight loop somewhere.
Consider a utility method to invoke ...
I'm trying to create an application that will let me execute a method specified at runtime on an arbitrary webservice (the URL of which I'll also provide at runtime). I've figured out how to use Type.InvokeMember to execute the arbitrary method, but how do I specify the web service to consume without creating a proxy class.
I found htt...
I guess this could also be asked as to how long the created type name is attached to an anonymous type. Here's the issue:
A blog had something like this:
var anonymousMagic = new {test.UserName};
lblShowText.Text = lblShowText
.Text
.Format("{UserName}", test);
As sort of a wish list and a ...
What I'm wondering is if it's possible to (for instance) to walk up the stack frames, checking each calling object to see if matches an interface, and if so extract some data from it.
Yes, I know it's bad practice, I'm wondering if it's possible.
...
How do you go about creating an instance of an object when given the class name as a string in an ASP.NET v2 application? For example, I've got a class called SystemLog defined in the app_code section of the application. The class is defined within the Reports namespace. To create an instance of the object, I do something like this:
Dim...
I have the following classes:
public class Person
{
public String FirstName { set; get; }
public String LastName { set; get; }
public Role Role { set; get; }
}
public class Role
{
public String Description { set; get; }
public Double Salary { set; get; }
public Boolean HasBonus { set; get; }
}
I want to be abl...
Or, in other words, what is wrong with something like -
new Method[] {Vector.add(), Vector.remove()}
Eclipse keeps telling me that I need arguments. But I obviously don't want to call the methods, I just want to use them as objects! What to do?
...
I am extending my Object Property Value Diff but I realized if an object has too many properties I may not want to diff them all. So I came up with the
public class IgnorePropertyDiffAttribute : System.Attribute
{
}
so that I can mark the properties I want the diff to ignore. However I don’t want to pollute my domain object with [Ign...
Is there a straightforward way using reflection to get at the parameter list for a delegate if you have its type information?
For an example, if I declare a delegate type as follows
delegate double FooDelegate (string param, bool condition);
and later get the type information for that delegate type as follows
Type delegateType = typ...
I understand the reflection API (in c#) but I am not sure in what situation would I use it. What are some patterns - anti-patterns for using reflection?
...