using global::System.Reflection; namespace Pilz.Reflection.PluginSystem { public class PluginFunction { /// /// Gets the method to invoke when invoking this PluginFunction. /// /// public MethodInfo Method { get; private set; } /// /// Gets the refered Plugin for this PluginFunction, if it has one. /// /// public Plugin Plugin { get; private set; } /// /// Gets the Parameters that was given by the attribute. /// /// public object[] Params { get; private set; } /// /// Gets the function code for this PluginFunction. /// /// public string FunctionCode { get; private set; } /// /// Creates a new instance of a PluginFunction. /// /// The Method to invoke when invoking this PluginFunction. /// The Plugin that is the Parent of this PluginFunction. This value can be NULL. public PluginFunction(MethodInfo method, Plugin plugin) { Method = method; Plugin = plugin; } /// /// Creates a new instance of a PluginFunction. /// /// The Method to invoke when invoking this PluginFunction.. /// The Plugin that is the Parent of this PluginFunction. This value can be NULL. /// The Parameters that was given by the attribute. /// The function code for this PluginFunction. public PluginFunction(MethodInfo method, Plugin plugin, object[] @params, string funcCode) : this(method, plugin) { Params = @params; FunctionCode = funcCode; } /// /// Invokes the Method of the PluginFunction. /// public void Invoke() { Method.Invoke(null, null); } /// /// Invokes the Method of the PluginFunction. /// public void Invoke(params object[] @params) { Method.Invoke(null, @params); } /// /// Invokes the Method of the PluginFunction and returns the return value. /// public object InvokeGet(params object[] @params) { return Method.Invoke(null, @params); } } }