reflection

Java reflection (and annotations): bean.class is empty

I jave a simple Java bean with 4 attributes, getter/setter, and some overided methods like toString, equals and hashCode. Above every Attribute is a custom Annotation: import java.lang.annotation.*; import java.lang.annotation.RetentionPolicy; @Target(ElementType.FIELD) @Retention( RetentionPolicy.RUNTIME ) public @interface DAOProper...

get all classes in classpath

hi all how can i get list of all available classes in classpath at runtime?! as i know in eclipse IDE by pressing crtl+shift+T it is possible to do such thing is there any method in java to get it done? thanks in advance ...

Use Dynamic or Reflection.emit

I'm new to C# and would like to ask for some direction on solving the following problem. I've got a xml file used as a template (without knowing its content in advance). something like: <Object> <Property name="ID"> <Value weight="40">10000</Value> <Value weight="60">20000</Value> </Property> <Property name="Name"> <V...

Assign method to delegate through reflection

Hi I got stuck up while dynamically assigning methods to a delegate instance through reflection. Below is a sample scenario of the situation i am faced with. class Program { static void Main(string[] args) { new DynamicDelegateTest().Test(); } } public class DynamicDelegateTest { public void Test() ...

Serialize IDictionary of objects

I'm writing a logging framework and need to serialize each object in an IDictionary<string,object>. Object can be a simple string, int etc. or a complex business object or a collection of either. Therefore I need a flexible method for doing this. At the more complex end of things I'd like the output to be something like: Object = IList...

embed a variable inside an f# quotation

i'm writing an F# dsl for SQL (http://github.com/kolosy/furious). A select statement would look like this: type person = { personId: string firstname: string lastname: string homeAddress: address workAddress: address altAddresses: address seq } and address = { addressId: string street1: string zip: st...

ReflectionClass cast to "normal" Class

Hello, I have a class TableData with two magic methods. One is the constructor and the other is the __call method. I have realized the invoke with following code: $class = new ReflectionClass('TableData'); $class->newInstanceArgs($parArray); It work great. But now I want to use my magic method. So I call $class->getData(), but it do...

Set Value of Private Static Field

I want to set the value of a private field using reflection for unit testing. Problem is, that field is static. Here's what I'm working from: /** * Use to set the value of a field you don't have access to, using reflection, for unit testing. * * Returns true/false for success/failure. * * @param p_instance an object t...

App.config <bindingRedirect/> for assembly with Strong Name and then use Short Name in C#

I think Title is not very suggestive in what I meant to ask, so theres is an example. I have this method that receives a name of System.Windows.Forms Control and then returns the type. (I need to use Version=2.0.0.0 of System.Windows.Forms) return Type.GetType("System.Windows.Forms." + name + ", System.Windows.Forms,Culture=neutral, Ve...

How to get concrete type of a generic interface

I have an interface public interface FooBar<T> { } I have a class that implements it public class BarFoo implements FooBar<Person> { } With reflection, I want to take an instance of BarFoo and get that the version of FooBar it implements is Person. I use .getInterfaces from BarFoo to get back to FooBar, but that doesn't help me fin...

Ants Profiler: How to optimize time spend in "Assembly load or unload"

Hi; I am using Ants Profiler to profile my ASP.Net application. The profiler shows the system spend nearly 30% time in "Assembly load or unload" and there was a hit count of 65. Any ideas on how can I optimize the "Assembly load or unload" time?? My ASP.Net application consists of nearly 10 project\dll references. The asp.net applicati...

Searching all execution paths of a codebase to see where "Int.TryParse" is called

I have a system which reads strings from the parameters of a GET request, then parses and sends the data along through a very large and complex codebase, which I can't reasonably wrap my head around. These parameters were originally generated from integers at the client, so at it would have been valid to parse these string parameters int...

Given an arbitrary javascript object, how can i find its methods?

I know this is possible in python, but can i get a list of methods for a javascript object? ...

using c# reflection to call a constructor

i have the following senario: class Addition{ public Addition(int a){ a=5; } public static int add(int a,int b) {return a+b; } } i am calling add in another class by: string s="add"; typeof(Addition).GetMethod(s).Invoke(null, new object[] {10,12}) //this returns 22 i need a way similar to the above reflection statement to create ...

Getting System::Type from IronRuby class

I have an IronRuby script like this one: class MyClassA < NamespaceMaze::BaseClass description = "I'm MyClassA" # <snip> some methods end class HelperClass; end class MyClassC < NamespaceMaze::BaseClass description = "I'm MyClassC" # <snip> some methods end And a .net class like this one: namespace NamespaceMaze { ...

printing local variable at runtime on demand?

Is it possible for me to print all the local, instance variable at runtime on demand. By on Demand I mean like we have jdb -attach <port> which we do at runtime and then we can start debugging... likewise I want to just print all those variables instead of debugging. is it possible? For example as can be seen, MyDebuggerExample make a c...

Get a static property from class in actionscript

I have this class package somePackage { public class SomeClass { public static const FOO: SomeClass = new SomeClass("0"); public static const BAR: SomeClass = new SomeClass("1"); } } I want to be able to get those static property given it's name. Example: public static function getProperty(propertyNam...

fluent nhibernate - how to get mappings from mapping classes

Given the following class: class XMap : ClassMap<X> { HasMany(x => x.ListOfY); HasManyToMany(x => x.ListOfZ); } I need a way to read these mappings. Is there a way to detect these? I need something like: XMap map = new XMap(); var t = GetMappingType(map, "ListOfY"); // somehow returns many-to-one var t = GetMappingType(map, "...

How do I add a custom attribute to a templated ascx file?

I would like to decorate my ascx with an attribute so that when I search for types that have that attribute it will appear. The issue is that it seems like I can only add it to the base class which means that when I do a LoadControl on the type I don't get the ascx file, I get base class. I'm trying to avoid having controls require being...

How to determine method parameter types during runtime in C/C++ under .NET ?

Hi all, in C# it is possible by using reflection to determine parameter types of some method as well as class members (method, properies..). I suppose that this is possible because of IL and .NET technology, right ? If so is it possible to use reflection or some similar technique for C/C++ writen under Visual studio 2005/2008/2010 .NET...