reflection

Get all classes inside a namespace

How can I get all classes inside a namespace? ...

Using reflection to get all classes of certain base type in dll

I have a dll that contains a number of classes that all inherit from a CommandBase class. I'm trying to get instances of all of these classes (CommandA, CommandB, CommandC, etc...) using reflection in C# so that I can call a specific method on each one. Here is what I have so far: //get assemblies in directory. string folder = Path.Comb...

Entity Framework 4.0 - Get By ID Using Generics and Reflection

I am looking to be able to load an entity by ID using generics and property reflection but am unsure how to accomplish this task using Entity Framework 4.0. I have a method in my abstract method as such: public abstract T GetById(object id, TestContext context); Currently, since it is abstract, I have to implement this method in ever...

Determine Primary Keys of an Entity using the Context in Entity Framework 4.0

I have several entities generated from my Entity Framework data model. In the .edmx file I can see the properties that are flagged as primary keys. My POCO's/custom context are generated from this and the T4 templates. I am looking for a way to find out the primary keys of my entities using reflection with Entity Framework 4.0. Is there...

Java - Get reference to a static class using reflection

In Java, is it possible to access an instance of a static class (nested) using reflection? Supposing I have the following 2 classes defined in the package Package1.SubPackage.SubSubPackage: public class MyMainClass { public static class SalesObjectGrouper1 { public static final GrouperContext CONTEXT = new GrouperContext("...

how to make an instance of an unknown class to use as a parameter for a method invocation using reflection?

ok heres the deal, im grabbing all the methods from a webservice and providing a way to test them. so far we are displaying their methods and some of the methods only deal with ints and strings. that part is taken care of. (we can invoke methods correctly and parse results) the problem is that some of these parameters needed for the met...

How to trace all method invocations from a class?

Hi, I want to trace all invocations of methods from a Foo class. Another class that would override all the methods from Foo like this... @Override public void blah() { System.out.println("blah()"); super.blah(); } ...would do - but do I really need to override them all (over 100 methods)? Can this be done in some smarter wa...

php ReflectionClass

hey all i want to use ReflectionClass to load some classes defined in my xml file but i am getting an error Error while register class :Class ReportErrorHandler does not exist i will not get this error when i will use require_once( 'handlers/system/ReportErrorHandler.php' ); but i dont want to require_once the class ,this is w...

Cloning/Copying get accessor body to new type

Hi, I'm creating new type in dynamic assembly from existing type, but with only selected properties to include: public class EmitTest { public Type Create(Type prototype, Type dynamicBaseType, List<string> includedPropertyList) { AssemblyName aName = new AssemblyName("DynamicAssembly"); AssemblyBuilder assemblyB...

If reflection is inefficient, when is it most appropriate?

I find a lot of cases where I think to myself that I could use relfection to solve a problem, but I usually don't because I hear a lot along the lines of "don't use reflection, it's too inefficient". Now I'm in a position where I have a problem where I can't find any other solution than to use reflection with new T(), as outlined in thi...

PHP: How is it possible to rename methods?

Is it possible to rename a class method in PHP 5.2 during run time? Is it possible to do that using Reflection? Given: class Test { public function myMethod() { echo 'in my method'; } } I want to be able to rename myMethod() to oldMethod() so that later I do this: $test = new Test(); $test->oldMethod(); // in my ...

Can Javascript get a function as text?

Can Javascript get a function as text? I'm thinking like the inverse of eval(). function derp() { a(); b(); c(); } alert(derp.asString()); The result would be something like "a(); b(); c();" Does it exist? ...

Besides serialization, what would be the legitimate uses of reflection to access private members?

Reflection can be used to access just about any object's internals, which is kind of not cool. I tried to list the legitimate uses of it, but in the end only serialization came to my mind. What other (legitimate) uses can you find to using reflection in order to access otherwise inaccessible members? EDIT I mean stuff you can't do if y...

Can a field's transient property/flag be set through reflection in java?

Is there a simple way to specify if a field should be transient or not in Java with reflection, similar to how a field's accessibility flag can be set with setAccessible()? ...

How do I get the overload through reflection at runtime?

Hi, Since where I work force me to use stored procedures and I haven't been around long enough to prevent it I have customized LiNQ to SQL code generation for all our stored procedures. Yes that's right we have stored procedures for ALL our data access and since we don't have table access it means that we often end up with 3 classes for...

Problems with reflection within Rails

I have a Rails app representing a card game. There are several different types of card, and a few expansions for the game, each providing more cards. So I'm using a single cards table and STI, with each expansion having a models subdirectory and appropriately-named module. Like this: app/models - card.rb + base_game - foo.rb - cla...

Using reflection, how do i detect properties that have setters . .

i have this code to loop through an object and get all of its properties through reflection foreach (var propertyInfo in typeof(TBase).GetProperties(BindingFlags.Public | BindingFlags.Instance)) { var oldValue = propertyInfo.GetValue(oldVersion, null); } how can i do a check to only look at properties that have a "Set" o...

Given a java object can I confirm its a bean persist-able by hibernate

there are times when I want to pass in an object to say an Auditing layer whose sole job is to persist the entities (no matter what type) , but since this is a public API, I want to ascertain that the passed in object is a hibernate entity bean and then only try the saveOrUpdate() ...

(Why) Is Reflection so expensive in .Net?

Possible Duplicate: What is the cost of reflection? Does anyone have a good explanation of the generally accepted mantra that reflection == bad performance? For example, how expensive is it to iterate over a type's properties collection and extract all property values from an instance of this type compared to just accessing ...

ReflectionTypeLoadException for Microsoft.Web.Administration running Test Project in VS2010

We have recently upgraded all our VS2008 projects to VS2010. Our code base is still targeting framework version 3.5, but I'm sure most of you would know that test projects must be upgraded to framework version 4.0. We have one particular set of tests that do not work now that the test project is targeting framework 4.0. These tests al...