示例#1
0
        private void RunPlugin(Plugin plug)
        {
            Type ty = GetTypeForFileName(plug.FileName, plug.Type);//Assembly.LoadFrom(plug.FileName).GetType(plug.Type);

            if (ty == null)
            {
                throw new Exception(string.Format("The plugin {0} could not load the type. Are yo missing the Assembly Filename? ", plug.Name));
            }
            try
            {
                CheckAndRunDependencies(plug);
                object obj = Constructor.Create(ty);
                obj = InjectInputs(obj, plug);
                MethodInfo runMethod = ty.GetMethod(plug.RunMethod);
                runMethod.Invoke(obj, new object[] { });
                PlugsRegistry.AddLoadedPlugin(plug, obj);
                PlugsRegistry.ExtractOutputs(obj);
                string parent = obj.GetType().BaseType.ToString();
                if (parent == "System.Windows.Forms.Form" && WinForm == null)
                {
                    this.WinForm = obj;
                }
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("The plugin {0} couldn´t initialize", plug.Name), e);
            }
        }
示例#2
0
        /// <summary>
        /// Call all plugins called by this plugin
        /// </summary>
        /// <param name="obj">The plugin that calls the dependent plugins</param>
        public void CallPlugins(object obj)
        {
            PlugsRegistry.ExtractOutputs(obj);
            List <Plugin> plugs = PlugsRegistry.GetCalledPlugins(obj.GetType());

            if (plugs != null && plugs.Count > 0)
            {
                foreach (Plugin item in plugs)
                {
                    RunPlugin(item);
                }
            }
        }