|
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace NParallel.Core
{
class Reflection
{
internal static object InvokeMethod(object target, string method, params object[] args)
{
bool bStatic = false;
Type type;
if (target is Type)
{
bStatic = true;
type = (Type)target;
}
else
{
type = target.GetType();
}
if (bStatic)
{
return type.InvokeMember(method, BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic , null, null, args);
}
else
{
return type.InvokeMember(method, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic, null, target, args);
}
}
internal static object GetFieldValue(object target, string method)
{
Type type = target.GetType();
return type.InvokeMember(method, BindingFlags.GetField, null, target , null);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Leaf is a software developer based in ShangHai China.
My major programming languages are C#/C++.
I am very interested in distributed system design and rich client development.
Current I am working on
NParallel.