reflection

Query assembly

I have a .NET assembly that has tens of classes and methods which are unit testing methods. I want to generate a report with all the method marked with attribute Ignore, do you know a simple way to do that? ...

Type.GetType(string) using "Generic<T>" syntax?

I'm building a generic ASP.NET server control that has an attribute used to specify a type name. I'm using a control builder to generate the generic version of my control by passing the attribute value to Type.GetType(string). This works great. However, if the type that I want to specify is generic, I have to use syntax like this: <gwb:...

What use is Reflection in .NET?

Possible Duplicates: When do you use reflection? Patterns/anti-patterns What exactly is Reflection and when is it a good approach? What is the need for reflection in .NET? What are the situations where it comes in handy? ...

Dynamic Forms Control Properties

I'm creating a capture form on the fly based on a set of metadata held in a EAV type schema. My trouble is in load the data back to the control, and in particular a winforms combobox. Also using Entity Framework for the data that is bound to the control. Check is control exist, else create. for each mapped property set their values. ...

How to get Classes and methods from a .cs file using Reflections in C#.?

How to get the classes that are available in a '.cs' file.? Like we can get the classes and methods in an Assembly using, Assembly.GetTypes() and Type.GetMethods() to get the Class and methods in an Assembly. Similarly how to get all the classes present within a C# file(.cs file).? I need to get the classes in a .cs file from which i...

getting type T from IEnumerable<T>

hi, is there a way to retrieve type T from IEnumerable<T> through reflection? e.g. i have a variable IEnumerable<Child> info; i want to retrieve Child's type through reflection ...

Is it legal to use Reflector to analyze binaries when the owner forbids a viewing of the source?

I've been commissioned to perform a review of an application. Company A buys software from Company B. The software crashes often and is not performant. Company A hires me to review software and to inform them if the software is sound. Company B forbids me from viewing (or having access to) their source code citing that they own the i...

Cast a property to its actual type dynamically using reflection

I need to cast a property to its actual type dynamically. How do I/Can I do this using reflection? To explain the real scenario that I am working on a bit. I am trying to call the "First" extension method on an Entity Framework property. The specific property to be called on the Framework context object is passed as a string to the meth...

Reflection - getting properties of nested objects

refers to : http://stackoverflow.com/questions/906327/reflection-setting-type-of-returned-obj I have a object Call Jobcard with a few properties, one of which is another object called Customer with its own properties, one of which is another nested object called Adress. These 2 functions will be handling other object types as well. pr...

How does db4o instantiate objects ?

What mechanism does db4o use to instatniate stored objects ? My class isn't Serializable and doesn't provide zero argument constructor and the only constructor throws NullPointerException when it's argument is null. In spite of that db4o can still instantiate stored objects of that class (thugh with incorrect values). If I can underst...

Reflection in Java

How can i access a varible defined inside a method by using reflection? I have to create criteria in hibenate. Database is attribute based database. Let's talk about a movie. A movie can have many language and many genre. e.g. Movieid property value 1 Language Hindi 1 La...

How can I bind events to strongly typed datasets of different types?

My application contains several forms which consist of a strongly typed datagridview, a strongly typed bindingsource, and a strongly typed table adapter. I am using some code in each form to update the database whenever the user leaves the current row, shifts focus away from the datagrid or the form, or closes the form. This code is th...

using type returned by Type.GetType() in c#

Hello ! i've got a question about how is it possible (if possible :) to use a type reference returned by Type.GetType() to, for example, create IList of that type? here's sample code : Type customer = Type.GetType("myapp.Customer"); IList<customer> customerList = new List<customer>(); // got an error here =[ Thank You in Advance ! ...

Pass FieldName as a Parameter in C#

I'm not quite sure what I'm attempting to do is called, so I'm struggling to find any clues from google. I have a couple of methods with the same logic in them, the only thing that differs is the property they are using on an object. class Foo { public int A(Bar bar) { return bar.A * 2; } public int B(Bar bar) { ...

How to I get the property belonging to a custom attribute?

Hi, I need to find the type of the property that a custom attribute is applied to from within the custom attribute. For example: [MyAttribute] string MyProperty{get;set;} Given the instance of MyAttribute, how could I get a Type descriptor for MyProperty? In other words, I am looking for the opposite of System.Type.GetCustomAttrib...

.Net Use Reflection To Define OfType

I am using System.Reflection to load a type that I cannot otherwise load during design time. I need to pull all controls within a collection of this type, however, i the OfType command doesn't seem to like the reflection Syntax. here is "close to" what I got. Dim ControlType As Type = System.Reflection.Assembly.GetAssembly( _ ...

Objective-C Reflection for generic NSCoding implementation

Is there any means of reflection in Objective-C that would allow you to write generic NSCoding implementations by inspecting the public properties of an object and generating generic implementations of encodeWithCoder: and initWithCoder: . I'm thinking of something like XStream for Java that allows a generic way to serialize and deseria...

Changing a return type depending on the calling method

Basically what I want, istwo public methods with slightly different return values to call the same method to do whatever work is needed. They both return the return value of the private method, however the private method will know how to return the correct value depending on the public method that called it. Example methods: public Map...

How to get the name of property

How do I make the method shown below to return the name of the property public class MyClass { private string _MyProperty = "TEST"; public string MyProperty { get { return _MyProperty; } set { _MyProperty = value; } } public string GetName() { return _MyProperty; // <- should return "MyProperty"; } } i don't wana use r...

Invoke method by MethodInfo

I want to invoke methods with a certain attribute. So I'm cycling through all the assemblies and all methods to find the methods with my attribute. Works fine, but how do I invoke a certain method when I only got it's MethodInfo. AppDomain app = AppDomain.CurrentDomain; Assembly[] ass = app.GetAssemblies(); Type[] types; foreach (Assemb...