methodinfo Questions

8

Solved

We can use a C# typeof keyword when we want to get Type instance for specified type. But what can I use if I want to get MethodInfo of a method by it's reference? For example I have a simple cons...
Lineup asked 21/2, 2012 at 17:30

6

Solved

I do some type analysis in runtime using Reflection. If I have a MethodInfo instance, how can I figure out if this is a "real" method or is a getter/setter method of a property? And if it is a prop...
Salazar asked 6/2, 2009 at 12:39

3

Solved

I need a method that takes a MethodInfo instance representing a non-generic static method with arbitrary signature and returns a delegate bound to that method that could later be invoked using Dele...
Vicious asked 3/5, 2013 at 17:4

3

Solved

I have a MethodInfo of an interface method and Type of a class that implements the interface. I want to find the MethodInfo of the class method that implements the interface method. The simple met...
Jibber asked 11/7, 2009 at 12:38

6

Solved

given public Class Example { public static void Foo< T>(int ID){} public static void Foo< T,U>(int ID){} } Questions: Is it correct to call this an "overloaded generic method"?...
Wrote asked 25/2, 2009 at 22:12

3

Solved

Using reflection to obtain a MethodInfo, I want to test if the type returned is typeof System.Void. Testing if it is System.Int32 works fine myMethodInfo.ReturnType == typeof(System.Int32) but...
Marciamarciano asked 30/11, 2009 at 14:47

2

Solved

Here is my test code: the extension method GetInstructions is from here: https://gist.github.com/jbevain/104001 using System; using System.Linq; using System.Reflection; using System.Threading.Tas...
Murtha asked 9/9, 2019 at 19:21

3

Solved

I wrote the extension method GenericExtension. Now I want to call the extension method Extension. But the value of methodInfo is always null. public static class MyClass { public static void Gene...
Bax asked 10/4, 2013 at 13:19

2

Solved

I am currently running into an issue trying to create delegates from MethodInfo. My overall goal is to look through the methods in a class and create delegates for ones marked with a certain attrib...
Prophylaxis asked 20/6, 2012 at 13:13

4

Solved

I'm trying to determine if the MethodInfo object that I get from a GetMethod call on a type instance is implemented by the type or by it's base. For example: Foo foo = new Foo(); MethodInfo metho...
Clepsydra asked 11/6, 2009 at 17:3

3

Solved

I have the MethodInfo of a method on a class type that is part of an interface definition that that class implements. How can I retrieve the matching MethodInfo object of the method on the interfac...
Puree asked 31/1, 2013 at 8:34

1

how can I reliably get MethodInfo (reflection) from IMethodSymbol (Roslyn syntax tree). I can get the Type from the IMethodSymbol, and the type has many methods, of which one matches the IMethodSym...
Trivium asked 29/5, 2015 at 11:33

1

var className = typeof(Console); var methodInfo = className.GetMethod("WriteLine",new [] { typeof(string) }); I got a methodInfo object for Writeline method , now if we see a defination of ...
Marvamarve asked 13/2, 2015 at 8:50

3

Solved

What is the most efficient way to ask a MethodInfo if it accepts parameters and, if so, how many? My current solutions would be: methodInfo.GetParameters().Any() and methodInfo.GetParameters().Co...
Endoscope asked 9/2, 2011 at 19:28

1

Solved

public abstract class BaseAspectAttribute : Attribute { protected internal virtual void OnMethodBeforeExecuting(object args) { Console.WriteLine("Base Attribute OnMethodBeforeExecuting Work"); ...
Rosenkrantz asked 29/7, 2014 at 17:0

1

Solved

I'm trying to get the method name passed into an Action delegate. This is what I have: private static void DoAction(params Action<Group>[] actions) { foreach (Action<Group> action in ...
Uraeus asked 5/4, 2013 at 20:22

1

Solved

I am a big fan of DRY coding, and I like to avoid boiler plate code as much as possible. Hence I have refactored all of my WCF channel faff into an AOP class, which deals with the lifecycle of the ...
Scirrhus asked 4/3, 2013 at 10:30

1

Solved

How do I get a return value (int) from a methodInfo.invoke? What makes it difficult for me is the fact that I use a string variable to call the method. Check the example below: if (Convert.ToBoo...
Ratchford asked 21/9, 2012 at 8:10

1

Solved

While migrating a project from VS2010 to VS2012, I ran into the following problem. The project is using Reflection a lot, and in order to get the MethodInfo from an interface the following code was...
Turpentine asked 28/8, 2012 at 20:8

2

Solved

I want to get an action delegate from a MethodInfo object. Is this possible?
Steviestevy asked 11/6, 2010 at 9:12

2

Solved

This is a question associated with another question I asked before. I have an overloaded method: public void Add<T>(SomeType<T> some) { } public void Add<T>(AnotherType<T>...
Perverse asked 5/5, 2012 at 18:44

3

Solved

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 ...
Hamlett asked 28/5, 2009 at 8:41

2

Solved

How can I pass a parameter as a reference with MethodInfo.Invoke? This is the method I want to call: private static bool test(string str, out byte[] byt) I tried this but I failed: byte[] rawAsm =...
Dragone asked 8/1, 2012 at 17:45

3

Solved

I have a need to invoke methods on a type through reflection using C#. At run-time, my data will consist of a Dictionary containing name/value pairs. The names in the Dictionary will correspond to...
Su asked 10/7, 2011 at 4:44

2

Solved

Is it possible to find out anything about a Method body with reflection? How?
Disunity asked 13/2, 2011 at 20:12

© 2022 - 2024 — McMap. All rights reserved.