Ejemplo n.º 1
0
        /// <summary>
        /// Executes a plugin method.
        /// </summary>
        /// <param name="pluginHandle">The plugin handle.</param>
        /// <param name="methodName">The method name.</param>
        /// <param name="args">Arguments for the method.</param>
        public static void ExecutePluginMethod(object pluginHandle, string methodName, params object[] args)
        {
            Contract.RequireNotNull(pluginHandle, out object PluginHandle);
            Contract.RequireNotNull(methodName, out string MethodName);

            PluginHandle.GetType().InvokeMember(MethodName, BindingFlags.Default | BindingFlags.InvokeMethod, null, pluginHandle, args, CultureInfo.InvariantCulture);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the value of plugin property.
        /// </summary>
        /// <typeparam name="T">The property type.</typeparam>
        /// <param name="pluginHandle">The plugin handle.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The property value.</returns>
        public static T PluginProperty <T>(object pluginHandle, string propertyName)
        {
            Contract.RequireNotNull(pluginHandle, out object PluginHandle);
            Contract.RequireNotNull(propertyName, out string PropertyName);

            object?Result = PluginHandle.GetType().InvokeMember(PropertyName, BindingFlags.Default | BindingFlags.GetProperty, null, pluginHandle, null, CultureInfo.InvariantCulture);

            return((T)Result !);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Calls a plugin function.
        /// </summary>
        /// <typeparam name="T">The plugin function return type.</typeparam>
        /// <param name="pluginHandle">The plugin handle.</param>
        /// <param name="functionName">The plugin function name.</param>
        /// <param name="args">Arguments for the function.</param>
        /// <returns>The function return value.</returns>
        public static T GetPluginFunctionValue <T>(object pluginHandle, string functionName, params object[] args)
        {
            Contract.RequireNotNull(pluginHandle, out object PluginHandle);
            Contract.RequireNotNull(functionName, out string FunctionName);

            object?Result = PluginHandle.GetType().InvokeMember(FunctionName, BindingFlags.Default | BindingFlags.InvokeMethod, null, pluginHandle, args, CultureInfo.InvariantCulture);

            return((T)Result !);
        }