Example #1
0
        private void LoadPlugins()
        {
            Process          p   = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();

            psi.CreateNoWindow = true;
            psi.ErrorDialog    = false;
            EnumPluginDirectory(DirectoryOnEnum);
            Thread.Sleep(2000);
            if (OnPluginsLoadComplete != null)
            {
                ClassHelper.AsyncInvokeDelegates(OnPluginsLoadComplete, DelegateInvoke_PreInvokeCallback, DelegateInvoke_PostInvokeCallback, new object[] { this, null });
            }
            //StartPlugins();
        }
Example #2
0
        private void DirectoryOnEnum(string path)
        {
            XReader xr;
            string  rlt = path;

            if (File.Exists(path))
            {
                string   typName;
                Assembly asm;
                xr = new XReader(path);
                try
                {
                    //instanceType = xr["Plugin"]["$Instance"].Value;
                    asm     = Assembly.LoadFrom(PluginDirectory + xr.Reset()["Plugin"]["$File"].Value);
                    typName = xr.Reset()["Plugin"]["$Type"].Value;
                    //						ModuleBase module = (ModuleBase)asm.CreateInstance(typName);
                    FunctionModule module = (FunctionModule)CreateModuleInstanceByTypeName(typName, asm);
                    if (module == null)
                    {
                        return;
                    }
                    module.BaseDir = path;
                    //module.ConfigFileFullPath = path + "\\Plugin.Config";
                    PluginItem pl = new PluginItem();
                    pl.Asm    = asm;
                    pl.Module = module;
                    bool isRegisted = RegistPlugin(pl);
                    if (OnPluginsLoad != null)
                    {
                        //OnPluginsLoad(this, pl);
                        ClassHelper.AsyncInvokeDelegates(OnPluginsLoad, DelegateInvoke_PreInvokeCallback, DelegateInvoke_PostInvokeCallback, new object[] { this, pl });
                    }
                }
                catch (Exception e)
                {
                    //MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Exceptions.Log(e);
                }
            }
        }