reflection

Dynamically retrieve values of index properties in C#

I am trying to create a SortedList of property names and values for any object. The two methods below iterate an object's properties storing its respective values in a sorted list (if there is a better mechanism for accomplishing this please recommend it). With my current implementation I am running into issues with Index Properties. Ob...

How do I convert a type to a string that can be compiled in vb .net?

I need a function that will convert a type to a string, for example: Dim foo as Dictionary(of Dictionary(of Integer, String), Integer) Debug.WriteLine(TypeToString(GetType(foo))) In the debug output, I'd expect to see something equivalent to: Dictionary(of Dictionary(of Integer, String), Integer) ...

Dynamic Inheritance

hi there I am writing a program and I have some class that doesn't extend any class. I want to know if dynamic inheritance at runtime is possible. I mean if one or more classes can derive from a class at runtime. ...

Monitoring changes to object field data "from the outside"

Let's say I have a regular simple Java class, such as: public class Foo { private int data; public int getData() { return data; } public void setData(int data) { this.data = data; } } ...and I now wish to, retroactively (i.e. without changing Foo's implementation), do some magic so that I can moni...

Traversing Scheme function as a list

Isn't it possible to treat functions in Scheme as any other list? Basically, what I want do to is something like this: (define (foo) "hello") (cdr foo) ; or similar, should return the list ((foo) "hello") I've found a similar discussion about this, and I feel a bit disappointed if this is not possible with Scheme. If so, why is th...

How to get rid of previous reflection when reflecting a UIImageView (with changing pictures)?

Hi everyone, I have managed to use the reflection sample app from apple to create a reflection from a UIImageView. But the problem is that when I change the picture inside the UIImageView, the reflection from the previous displayed picture remains on the screen. The new reflection on the next picture then overlaps the previous reflecti...

How to get type of TKey and TValue given a Dictionary<TKey,TValue> type

I want to get type of TKey and TValue given a Dictionary<TKey,TValue> type. eg. If type is Dictionary<Int32,String> I want to know how to get keyType = typeof(Int32) and valueType = typeof(String) ...

Can I get parameter names/values procedurally from the currently executing function?

I would like to do something like this: public MyFunction(int integerParameter, string stringParameter){ //Do this: LogParameters(); //Instead of this: //Log.Debug("integerParameter: " + integerParameter + // ", stringParameter: " + stringParameter); } public LogParameters(){ //Look up 1 level in the ...

Can I programatically get hold of the Autos/local variables that is shown when debugging?

Im trying to build an error-logger that loggs running values that is active in the function that caused the error. (just for fun so its not a critical problem) When going in break-mode and looking at the locals-tab and autos-tab you can see all active variables (name, type and value), it would be useful to get hold of that for logging ...

How to invoke method in using reflection

Hi, How can I invoke a method with parameters using reflections? I want to the values to those parameters. Can somebody help? ...

Getting Class type from String

I have a String which has a name of a class say "Ex" (no .class extension). I want to assign it to a Class variable, like this: Class cls = (string).class How can i do that? ...

Accessing a class from different project

Hi, i want to access or get the class which is present in different project.How can i do that?Help Actually the using reflections i want to access a class from different package. Class class="class from another project" ...

Get Predicate<T> property info

I have a interface resembling the following: public IEnumerable<IDocument> Search(Predicate<IDocument> predicate) { ... } where an IDocument looks like this: public interface IDocument { string Id {get; set;} string Title {get; set;} ... } I am about to implement a document provider where I have to decompose the conten...

Can we view the methods of COM DLL or COM EXE and calling one by one at runtime.(Using Reflections)

Hello Can we call COM exposed interface METHODS at runtime one by one. This can be achieved in case of WIN32 DLL's using reflections. But SAME job need to be done with COM Dll or COM EXE, We'll be able to view all exposed methods of that COM DLL or COM EXE and ony by one we need to call all of them.(Remember I need to call unmanaged cod...

Can Object.GetType also be used for late binding?

a) Can Object.GetType also be used for late binding ( Book I’m reading says it can’t be used for late-binding )? For example, assuming we use late binding ( by dynamically loading an assembly A, calling A.GetType(“T”) and then calling Activator.CreateInstance) to create an instance (I) of type (T) not known at compile time and if we t...

Text transforms on all of objects properties, is there a better way?

Currently I am doing this: I have text that looks like: Hello ${user.name}, this is .... And I do this: public string TransformUser(User user, string text) { StringBuilder sb = new StringBuilder(text); sb.Replace("${user.name}", user.Name); ... ... return sb.ToString(); } Is there a better way, maybe using reflection ...

Reflecting constructors with default values in C#4.0

I've just started using C#4.0(RC) and come up with this problem: class Class1 { public Class1() { } } class Class2 { public Class2(string param1) { } } class Class3 { public Class3(string param1 = "default") { } } Type[] types = new Type[] { typeof(Class1), typeof(Class2), typeof(Class3) }; // Problem starts here, main-method for(int ...

InvokeMember using GetField. Field not found in VB.NET

This is probably a simple one but I can't seem to figure it out. I have a bunch of form items created by the form designer declared as (in frmAquRun.Designer.vb) Public WithEvents btnAquRunEvent1 As VisibiltyButtonLib.VisibilityButton Public WithEvents btnAquRunEvent2 As VisibiltyButtonLib.VisibilityButton ... etc And I basically wa...

Are there any frameworks or utilities (in the .NET space) for automatically generating data transfer objects from business objects

I'm looking for the best approach for generating data transfer objects from business objects (the type definition, not mapping the data) using a set of conventions (e.g. all public properties), and possibly configurable to determine how deep to go. I realize that this may not be possible or even desirable for many cases where the dto's ...

GetType() and passing on parameters and an objectname

Is there a way to call a method from a class and passing on some parameters with getType() by passing on the objectname of the class? public void ForeachInsert(object tblnaam, string error) { tblnaam.GetType().GetMethod("nameOfMethod"); //where to place string error? } ...