reflection

How to identify duplicate assemblies?

While l was looking over some questions about MEF, I stumbled onto this particular answer to a question. It made me wonder about such a bit since I've never had to attempt such but can see it being very valid in the scenario of that question. Scenario: If you have a directory of various .Net Assemblies all named different, how would yo...

Is there anything inherently dangerous about instantiating a dojo class like this?

I need to be able to instantiate an object of a class in Dojo at runtime and mix it into another object (kind of like specifying an extends or an implements in Java, but at runtime). and I came up with the following solution: var declaredClassBackup = this.declaredClass; // backup the "declaredClass" var mixinObject = null; try { ...

Quick question regarding reflection and permissions. .net 2008

I have various projects that use reflection to access and invoke private or internal members in some of the framework classes. These projects all work fine on my machine (running visual basic express 2008), but are they guaranteed to work on another machine, or, say, over a network? I've had a look at ReflectionPermission, but I'm not ...

Dynamic code generation

I am currently developing an application where you can create "programs" with it without writing source code, just click&play if you like. Now the question is how do I generate an executable program from my data model. There are many possibilities but I am not sure which one is the best for me. I need to generate assemblies with classes...

Is it ok for "mappers" to use reflection

In my limited experience, it seems that a common idiom is to pass objects from one layer to another using a "mapper". An ORM is one example, to go map from the Domain to the database and back. Automapper is another, which facilitates mapping from a rich domain object, into an object consumable by another layer (ViewModel, WebService. So...

How can I coax an object to a IList<T>?

I am using reflection along with linq.Dynamic, and I am having a small problem with creating a query that needs to get IQueryable<T> from an IList<T> or ISet<T> when I currently have an object. At first I thought I could write a little helper method: object Helper<T>( IList<T> list, string query, param object[] values ) { ... do quer...

Create an instance of a Type, provided as a parameter to a method

The class to instantiate: public class InstantiateMe { public String foo { get; set; } } Some pseudo-code: public void CreateInstanceOf(Type t) { var instance = new t(); instance.foo = "bar"; } So far I'm figuring that I need to use reflection to get this done, given the dynamic nature of what I...

How do you get the name of a generic class using reflection?

How do you get the name of a generic class using reflection eg public class SomeGenericClass<T> { } SomeGenericClass<int> test = new SomeGenericClass<int>(); test.GetType().Name returns "SomeGenericClass'1" How do I get it to return "SomeGenericClass" without the '1? ...

Java Reflective Method Call with Generics

Given this method: public final void foo (List<MyClass> bar){ .. } I want to be able to call this method reflectively. In order for getMethod to work, I have to change it to: public final void foo (List bar){ .. } This does not seem right for obvious reasons, but no combination of inputs to getMethod seem to work otherwise. I have ...

Is it possible to modify methods of an object instance using reflection

What I'm trying to do is create a domain model with a Plain Old PHP Object. The I'm creating a library which will do all the infrastructure stuff. So one of my models looks like this class Project { public $id; public $name; public $typeId; private $type; public function getType() { return $this->type; } public func...

Hiding Public Functions

Hi, This is a fairly generic question in that I'm just wondering what potential options there are for this. Say, I have a simple class: Public Class Example Private _One As String Public Property One() As String Get Return _One End Get Set(ByVal value As String) _One = val...

how to call anonymous delegate dynamically

I hava a delegate public delegate void Context(); And i had implemented it by anonymous method, public Context fakeHttpContext = () => { ... create fake http context. }; I dont' want to execute the fakeHttpContext by fakeHttpContext.Invoke() I wonder if i could invoke it by ...

getClass().getMethod("name", unkown)

For a really abstract application I am creating, I need to call methods without knowing their parameter types and only knowing the parameters in a String shape. Let say I have the method; getNames(String like, int amount); and I have a array of strings containing the 2 parameters, so lets say I have; String[] params = new String[] {...

What's the use of having private properties if you can alter them with reflection?

I know it sounds like a stupid question, but how safe is your API if you can access private properties and change them? ...

Automapper, generics, dto funtimes

Here's the deal: I have a report designer where users can create reports based on some predefined datasets. They can select a set of columns to include in the report and then, when the report is ran, an IList is created by mapping the NHibernate collection over to the dto class collection using automapper. The problem with this is tha...

Is there any difference between assemblies compiled from WebApplication and ClassLibrary projects?

In other words, if I have a compiled dll file, is there a way to find out (using Reflection) whether this dll is produced from a WebApplication, ClassLibrary or another project type? Is there any difference at all? ...

AS3 reflection. How to find out if a method is overridden?

Is it possible to use AS3 reflection to find out if a method was overridden? I need a method like: protected function isOverriden(methodName:string) : bool { //magic here! //... return awesomeLocalVariable; } So, I pass in the method name as a string and the isOverridden method yields true only if and only if the object...

How can I tell if a javascript object is an Image or a Canvas?

I have a class with a property that can be an Image (i.e. an IMG element) or a Canvas. When I serialize it to JSON, I need to convert this to a text string. If it is a Canvas, then I can call Canvas#toDataURL. But if it is an Image, I first need to draw it to a Canvas with Canvas#drawImage, then serialize that canvas with toDataURL. So ...

Java Reflection not working on my system - working for team members

I am working on a team project in Java. One requirement is that we dynamically populate a drop-down menu of all classes that implement a certain interface. New classes can be added after compile time. To accomplish this we are using reflection. Problem: All of the drop-down menus are blank on my system. I cannot for the life of me figur...

Building core shop framework in Rails. Suitable or not?

I work at an in-house IT department for company running 10 or so only shops of varying complexity. The shops code has been written over the last 8 years, each shop a new branch growing father and father away from the stem (I guess that makes it a bush?) The need for more and more complex discounts, campaigns and user monitoring are grow...