reflection

How do I go about using ReflectionFunction on filter_input() ?

This is what I got so far; <?php ReflectionFunction::export(new ReflectionFunction(filter_input())); And I get this error: Warning: filter_input() expects at least 2 parameters, 0 given in C:\wamp\www\POS\Ch4\inspect_filter_input_function.php on line 2 If I get rid of the parentheses, I get a warning but I the function's info. If I p...

Find type given generic base type and implemented type.

Here is what I have. BaseClass<T> { } MyClass { } NewClass : BaseClass<MyClass> { } I need to see if there is a class that implements the BaseClass with the specific generic implementation of MyClass and get the type of that class. In this case it would be NewClass Edit AppDomain.CurrentDomain.GetAssemblies().SelectMany(s => s.Ge...

How to set default values to the properties of dynamically loaded types at runtime for XML serialization

I need to serialize dynamically loaded types' classes using XMLSerializer. When using XML serializer non initialized values are not being serialized. I dont have control over the assemblies I am working with so can not use XML attributes for specifying default values on properties. So I think I need to set all properties and sub propert...

C# reflection avoid propertie

Im using reflection to acess a class tha represents a table in DB.However,reflection read all properties of that class,and im wondering if there're some atributte in c# we can use to avoid read that propertie. i.e: [AvoidThisPropertie] public string Identity { get; set; } ...

.NET generic class instance - passing a variable data type

As the title suggests, I'm tyring to pass a variable data type to a template class. Something like this: frmExample = New LookupForm(Of Models.MyClass) 'Works fine Dim SelectedType As Type = InstanceOfMyClass.GetType() 'Works fine frmExample = New LookupForm(Of SelectedType) 'Ba-bow! frmExample = New LookupForm(Of InstanceOfMyClass.Get...

How to assert that a class has an inherited attribute, but excluding the parent class at the same time?

I have two attributes - MigrationAttribute and TestDataMigrationAttribute : MigrationAttribute. How can I assert that a class has applied TestDataMigrationAttribute but not MigrationAttribute (which is the parent attribute class)? ...

Is it possible to call unmanaged code using C# reflection from managed code ?

Hi all, Is it possible using reflection and C# .NET to call dynamicly different function (with arguments) written in C or C++ before .NET came(unmanaged code) ? And smole C# example if possible would be appreciated! Thanks! Br, Milan. ...

.NET Reflection Helper API?

When using reflection we typically just was the basic System.Reflection API but I am wondering if anyone know of a nice "wrapper" layer or API that has a more "schema style" approach? (e.g. kind of like a code generators DB schema view) This is for use in code generators, like T4 templates etc... ...

Be notified of method calls in .NET

I want to be notified whenever a specific method has been called. I was hoping I could accomplish this using Reflection, but my attempts haven't gotten me anywhere. How can I be notified? I figured using MethodInfo was the way to go, but like I said, I found nothing there that could help me accomplish what I wanted to do. I cannot cha...

How to create a generic list in this weird case in c#

In my program, I have a class A which is extended by B, C and many more classes. I have a method GetInstance() which returns a instance of B or C (or of one of the other child), but I don't know which one, so the return type of the method is A. In the method CreateGenericList(), I have a variable v of type A, which is in fact either a B...

C#: returns array from object.

Hello, There is the next task: I need to check if input parameter (object) is array, then return array of input elements. For example I have input array like this: int [] array = {1,2,3,4}; And method private object[] GetArray(object @from) { } So, I need to check in this method that input variable is array and after return...

Is there a Tool for see files created with binary serialization?

I've working without problems serializating object graphs to and from files. Everything was fine until today: A dictionary, created in a constructor and NEVER deleted, was lost (null referece) just after deserialization from file, for the first time in more than a year doing the same without troubles. So, is there a Software Tool to loo...

Using System.Reflection to Get a Method's Full Name

I have a class that look like the following: public class MyClass { ... protected void MyMethod() { ... string myName = System.Reflection.MethodBase.GetCurrentMethod.Name; ... } ... } The value of myName is "MyMethod". Is there a way that I can use Reflection to get a value of "MyClass.MyMethod" for myNam...

ASP.NET Reflection get typeof current object

I am working on a project where all of our object have a standard base class. We just added some new fields to the database for the tables behind some of the objects e.g. "DateCreated". I would like to use reflection on the base class' insert method so that when it is called it checks the object to see if it has a property "DateCreated"...

What is reflection and what can it be used for in c#?

Possible Duplicate: Reflection. What can we achieve using it? I see plenty of examples of using reflection in c#, but I'm not sure exactly what all it is mainly used for in c#. So when do you use it? ...

How to make an unit test always pass?

Let's assume someone has to write a solution to a problem and I have to test his solution with some tests. Is it possible (maybe with reflections or something) his program to pass all my tests, but to have nothing in common with the real solution to the problem? ...

How to identify classes that implement an interface?

I have a VB6 EXE project with a large amount of classes - everything compiles to an EXE, there are not COM DLLs built. Some of the classes implement the IDataProcessing interface. How can I programmatically determine the classes that implement that interface? ...

Dynamically set generic type argument

Following on from my question here, I'm trying to create a generic value equality comparer. I've never played with reflection before so not sure if I'm on the right track, but anyway I've got this idea so far: bool ContainSameValues<T>(T t1, T t2) { if (t1 is ValueType || t1 is string) { return t1.Equals(t2); } ...

How do I access a JavaFX 1.3 static class member from Java?

I want to access a static JavaFX class member from Java using the Javafx reflection API. E.g. JavaFX code: public var thing; class MyJavaFXClass { } Java code: private Object getThing() { FXClassType classType = FXContext.getInstance().findClass("mypackage.MyJavaFXClass"); // Get static member 'thing' from 'MyJavaFXClass' //...

Is any simple way to create method and set its body dynamically in C#?

I hold body of method in string. I want to create method dynamically. But I don't know, how to set its body. I saw very tedious way using CodeDom. And I saw using Emit with OpCodes. Is any way to use ready code from string variable? string method_body = "return \"Hello, world!\";"; //there is method body DynamicMethod dm = new System.Re...