reflection

Create generic delegate using reflection

I have the following code: class Program { static void Main(string[] args) { new Program().Run(); } public void Run() { // works Func<IEnumerable<int>> static_delegate = new Func<IEnumerable<int>>(SomeMethod<String>); MethodInfo mi = this.GetType().GetMethod("SomeMethod").MakeGeneri...

Finding the PHP File (at run time) where a Class was Defined

Is there any reflection/introspection/magic in PHP that will let you find the PHP file where a particular class (or function) was defined? In other words, I have the name of a PHP class, or an instantiated object. I want to pass this to something (function, Reflection class, etc.) that would return the file system path where the class ...

Invoking methods with optional parameters through reflection.

I've run into another problem using C# 4.0 with optional parameters. How do I invoke a function (or rather a constructor, I have the ConstructorInfo-object and I know it doesn't require any parameters, but I still can't invoke it. Here is the code I use now: type.GetParameterlessConstructor().Invoke(BindingFlags.OptionalParamBinding |...

I'm confused about some Reflection code, and looking for insight.

I'm developing for the iPhone using C# and Mono's Full AOT technology. According to their Limitations page (link text), unlike traditional Mono/.NET, code on the iPhone is statically compiled ahead of time instead of being compiled on demand by a JIT compiler. When running on the hardware, the following exception occurs: ExecutionEngin...

Open Source Alternatives to Reflector?

Hi, Just to ask if anyone knows of an open source alternative to RedGate's Reflector? I'm interested in checking out how a tool similar to Reflector actually works. Thanks, MagicAndi. ...

C# Reflection and Access Modifiers on a Property

I have written some code to look at properties using reflection. I have retrieved a list of properties from the class using reflection. However I need to find out if the property is public or protected. eg: public string Name{get;set;} protected int Age{get;set;} The PropertyInfo class does not seem to expose this information about ...

How to know if a C++/CLI reflected parameter is long or int?

I'm reflecting a C++/CLI method that has the following signature: void foo(long n); This translates into C# as: void foo(int modopt(IsLong) n); How can I find if an int parameter is actually a C++/CLI long by reflection? ...

Why ParameterInfo::GetXXXCustomModifiers does not returns IsLong if the parameter is ByRef?

Given a ParameterInfo p from this: void foo(int modopt(IsLong) n); p.GetOptionalCustomModifiers() returns a System.Runtime.CompilerServices.IsLong; however, if the method signature happens to be: void foo(out int modopt(IsLong) n); It does not. Is there a work around for this? ...

Can I use reflection to find the bin/[Configuration] folder in ASP.NET instead of the asp temporary folder.

I have an ASP.NET website and I want to find the /bin/[Configuration] folder to use an external tool (an exe file). When I use reflection to get calling assemblies location it returns something similar to: C:\Windows\Microsoft.NET\Framework\\...\Temporary ASP.NET Files\a1388a5e\\...\my.dll Since each dll has its own directory under ...

Type patterns and generic classes in Haskell

I'm trying to understand type patterns and generic classes in Haskell but can't seem to get it. Could someone explain it in laymen's terms? In [1] I've read that "To apply functions generically to all data types, we view data types in a uniform manner: except for basic predefined types such as Float, IO, and →, every Haskell data t...

Obtaining reference to Class instance by string name - VB.NET

Is it possible using Reflection or some other method to obtain a reference to a specific class instance from the name of that class instance? For example the framework for the applications i develop heavily uses public class instances such as: Public bMyreference as MyReference = new MyReference Then throughout the application bMyRef...

How can a property resolve its own name and type with reflection?

Is there a way for a property to access its own name and type at runtime using reflection? I want to access this info without hard coding the name or index of the property in the class. Simple Example Code: Private ReadOnly Property MyProperyName() As String Get Console.WriteLine((Get Current Property Info).Type.ToString) ...

c# reflection: How can I invoke a method with an out parameter ?

I want expose WebClient.DownloadDataInternal method like below: [ComVisible(true)] public class MyWebClient : WebClient { private MethodInfo _DownloadDataInternal; public MyWebClient() { _DownloadDataInternal = typeof(WebClient).GetMethod("DownloadDataInternal", BindingFlags.NonPublic | BindingFlags.Instance); }...

C# Reflection StackTrace get value

I'm making pretty heavy use of reflection in my current project to greatly simplify communication between my controllers and the wcf services. What I want to do now is to obtain a value from the Session within an object that has no direct access to HttpSessionStateBase (IE: Not a controller). For example, a ViewModel. I could pass it in ...

What is this <Module> Type in an assembly

Each time I open an assembly in reflector, I see this special <Module> type that shows up. Recently, I came across an assembly that has a static method defined in this type and I want to invoke it through reflection. Is this possible? Btw, this method has privatescope hidebysig method attributes EDIT: Assembly assembly = Assembl...

How To Test if Type is Primitive

Hi Guys I have a block of code that serializes a type into a Html tag. Type t = typeof(T); // I pass <T> in as a paramter, where myObj is of type T tagBuilder.Attributes.Add("class", t.Name); foreach (PropertyInfo prop in t.GetProperties()) { object propValue = prop.GetValue(myObj, null); string stringValue = propValue != null ...

actionscript3: reflect-class applied on rotationY

Hi, I'm using a class which applies a visual reflection-effect to defined movieclips. I use a reflection-class from here: link to source. It works like a charm except when I apply a rotation to the movieclip. In my case the reflection is still visible but only a part of it. What am I doing wrong? How could I pass/include the rotation to ...

.net - invoke methods from classes from a certain namespace via reflection

SPL and PHP allows you to create objects on the fly from classes, that fulfill certain conditions, such as implementing certain interfaces and stuff like that. However, I would like to do something similar in c# and automatically create objects from all classes in a namespace and invoke a particular method from those classes that implem...

Reflect and Load code at design time in Visual Studio

I have an XML file that lists a series of items, and the items are often referenced by their name in code. Is there any way to use reflection within Visual Studio to make this list 'accessible' sort of like intellisence? I've seen it done before - and I'm pretty sure it's ridiculously difficult, but I figure it can't hurt to at least a...

How can I set opacity of the reflection when using -webkit-box-reflect?

I've been playing with the -webkit-box-reflect property in Chrome and can achieve a reflection that fades with the following code (it's example code from the Webkit blog): -webkit-box-reflect: below 5px -webkit-gradient( linear, left top, left bottom, from(transparent), color-stop(0.5, transparent), to(white) ); Problem is...