public static List <IPlugin> GetExecutePlugin()
        {
            string path = Assembly.GetExecutingAssembly()
                          .Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf("\\"));
            PluginCollection pluginconfigs = GetPlugins();
            List <IPlugin>   plugins       = new List <IPlugin>();

            //List<Type> plugintypes = new List<Type>();
            if (pluginconfigs != null && pluginconfigs.Count > 0)
            {
                for (var i = 0; i < pluginconfigs.Count; i++)
                {
                    var      filename       = path + "\\Plugin\\" + pluginconfigs[i].Name + ".dll";
                    Assembly pluginAssembly = Assembly.LoadFile(filename);
                    var      types          = pluginAssembly.GetTypes();
                    foreach (var type in types.Where(s => s.GetInterface(typeof(IPlugin).Name) != null))
                    {
                        IPlugin plugin = Activator.CreateInstance(type) as IPlugin;
                        plugins.Add(plugin);
                    }
                }
            }

            return(plugins);
        }
Example #2
0
        public static PluginCollection LoadCollectors()
        {
            PluginCollection loadedPlugins = new PluginCollection();

            string pluginFilter = "NodeCollector.*.dll";
            string dllDirectory = AppDomain.CurrentDomain.BaseDirectory;

            GVars.MyLog.WriteEntry(string.Format("Loading available collectors from directory {0} (filter {1})", dllDirectory, pluginFilter));

            // Search for all filtes matching the filter and try to load them
            string[] pluginFiles = Directory.GetFiles(dllDirectory, pluginFilter);
            foreach (string filename in pluginFiles)
            {
                try {
                    NodeCollector.Core.INodeCollector plugin = PluginSystem.LoadAssembly(filename);
                    loadedPlugins.Add(plugin);
                }
                catch (Exception ex)
                {
                    GVars.MyLog.WriteEntry(string.Format("Unable to load collector plugin {0}: {1}.", filename, ex.Message.ToString()), EventLogEntryType.Error, 0);
                }
            }

            // Log a list of loaded plugins to eventlog
            List <string> pluginNames = loadedPlugins.Select(x => x.GetName()).ToList();

            pluginNames.Sort();
            GVars.MyLog.WriteEntry(string.Format("Loaded plugins: {0}", string.Join(", ", pluginNames)));

            return(loadedPlugins);
        }
Example #3
0
        private static void InitPluginsByConfig(PluginCollection pluginList, string[] sortedPlugins)
        {
            if (sortedPlugins.Length == 0)
            {
                return;
            }

            //如果提供了配置信息,则完成按照配置中的插件列表来初始化,所以先清空该列表。
            pluginList.Clear();

            for (int i = 0, c = sortedPlugins.Length; i < c; i++)
            {
                var name = sortedPlugins[i];

                IPlugin plugin = null;

                //可以只填写程序集名称,也可以写出插件类型的全名称。
                if (!name.Contains(','))
                {
                    #region  照程序集名称来加载插件

                    Assembly assembly = null;
                    try
                    {
                        assembly = Assembly.Load(sortedPlugins[i]);
                    }
                    catch (Exception ex)
                    {
                        throw new InvalidProgramException(string.Format("无法加载配置文件中指定的插件:{0}。", sortedPlugins[i]), ex);
                    }
                    plugin = CreatePluginFromAssembly(assembly);

                    #endregion
                }
                else
                {
                    #region  照插件类型名称来加载插件

                    Type pluginType = null;
                    try
                    {
                        pluginType = Type.GetType(sortedPlugins[i]);
                    }
                    catch (Exception ex)
                    {
                        throw new InvalidProgramException(string.Format("无法加载配置文件中指定的插件类型:{0}。", sortedPlugins[i]), ex);
                    }
                    if (pluginType == null)
                    {
                        throw new InvalidProgramException(string.Format("无法加载配置文件中指定的插件类型:{0}。", sortedPlugins[i]));
                    }

                    plugin = Activator.CreateInstance(pluginType, true) as IPlugin;

                    #endregion
                }

                pluginList.Add(plugin);
            }
        }
        /// <summary>
        /// Iterate through all the child nodes
        ///	of the XMLNode that was passed in and create instances
        ///	of the specified Types by reading the attribite values of the nodes
        ///	we use a try/Catch here because some of the nodes
        ///	might contain an invalid reference to a plugin type
        ///	</summary>
        /// <param name="parent"></param>
        /// <param name="configContext"></param>
        /// <param name="section">The XML section we will iterate against</param>
        /// <returns></returns>
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            PluginCollection plugins = new PluginCollection();

            foreach (XmlNode node in section.ChildNodes)
            {
                try
                {
                    //Use the Activator class's 'CreateInstance' method
                    //to try and create an instance of the plugin by
                    //passing in the type name specified in the attribute value
                    object plugObject = Activator.CreateInstance(Type.GetType(node.Attributes["type"].Value));

                    //Cast this to an IPlugin interface and add to the collection
                    IPlugin plugin = (IPlugin)plugObject;
                    plugins.Add(plugin);
                }
                catch (Exception e)
                {
                    //Catch any exceptions
                    //but continue iterating for more plugins
                }
            }

            return(plugins);
        }
Example #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** Plugins examples ***");

            Console.WriteLine("***String to upper example***");
            var text = "Some Text";
            Console.WriteLine("Input text: " + text);
            new PluginHelper<string>(new StringToUpper(), text).PrintToConsole();
            Console.WriteLine("");

            Console.WriteLine("***Adding point to the end of the string***");
            var text1 = "Some Text1";
            Console.WriteLine("Input text: " + text1);
            new PluginHelper<string>(new StringAddPoint(), text1).PrintToConsole();
            Console.WriteLine("");

            Console.WriteLine("***Use plugin collection to apply multiple string plugins to text***");
            var text2 = "Some Text2";
            Console.WriteLine("Input text: " + text2);
            var pc = new PluginCollection<string>();
            pc.Plugins.Add(new StringAddPoint());
            pc.Plugins.Add(new StringToUpper());
            new PluginHelper<string>(pc, text2).PrintToConsole();
            Console.WriteLine("");

            Console.WriteLine("***Multiply value by 2 and return absolute value (Pluginable plugin example)***");
            var val = -29;
            Console.WriteLine("Input value: " + val );
            new PluginHelper<int>(new NumberMultiplyBy2WithPlugin(new NumberAbsoluteValue()), val).PrintToConsole();
            Console.WriteLine("");

            Console.ReadKey();
        }
Example #6
0
        //Hashtable FormList = new Hashtable();
        public MainForm()
        {
            InitializeComponent();

            //TODO: инициализация будущих коллекций и парсинг конфигов
            try
            {
                l = new Logger("log.txt");
            }
            catch (IOException e)
            {
                MessageBox.Show("Ошибка при открытии лога: \r\n\r\n" + e.Message);
                l = new Logger(null);
            }
            Config           cn = Config.Load("config", l);
            PluginCollection pc = PluginCollection.FindPlugins();

            ((Plugin)pc[0]).Checked = true;

            TempParameters.ParametersInstance            = Parameters.Parse(cn);
            TempParameters.ParametersInstance.PluginList = pc;
            //TempParameters.ParametersInstance.PluginList = PluginCollection.Synchronize(TempParameters.ParametersInstance.PluginList, pc);
            s = new Settings(TempParameters.ParametersInstance);

            foreach (Plugin pl in TempParameters.ParametersInstance.PluginList.SelectedPlugins)
            {
                TempParameters.CreateWindow(pl);
            }
        }
        private async Task SetPluginCollection()
        {
            var pluginList = await Task.Run(() =>
            {
                var pluginManager = new PluginManager(PluginDirectory);
                return(pluginManager.ValidPlugins(typeof(IDataEngineHostView))
                       .Select(token => new PluginViewModel(token))
                       .ToList());
            });

            PluginCollection = CollectionViewSource.GetDefaultView(pluginList);
            PluginCollection.GroupDescriptions.Add(new PropertyGroupDescription("Prefix", null, StringComparison.InvariantCultureIgnoreCase));
            PluginCollection.SortDescriptions.Add(new SortDescription("Prefix", ListSortDirection.Ascending));
            PluginCollection.SortDescriptions.Add(new SortDescription("PluginName", ListSortDirection.Ascending));
            PluginCollection.Filter += Filter;
            PluginCollection.MoveCurrentToFirst();

            var selected = JsonConvert.DeserializeObject <PluginConfig>(Settings.Default.SelectedPlugin ?? "");

            SelectedPlugin = pluginList.FirstOrDefault(p => p.PluginName == selected?.PluginName);
            if (SelectedPlugin != null)
            {
                SelectedPlugin.HostType         = selected.HostType;
                SelectedPlugin.TeradataHostType = selected.TeradataHostType;
                SelectedPlugin.RestartDelay     = selected.RestartDelay;
                SelectedPlugin.TestEmail        = selected.TestEmail;
            }
            else
            {
                SelectedPlugin = PluginCollection.CurrentItem as PluginViewModel;
            }
        }
Example #8
0
 /// <summary>
 /// Create a default instance of PluginManager.
 /// </summary>
 public PluginManager()
 {
     _plugins = new PluginCollection();
     _watchers = new Dictionary<string, FileSystemWatcher>();
     _lastRead = new Dictionary<string, DateTime>();
     _globalContext = new Dictionary<string, dynamic>();
 }
Example #9
0
        /// <summary>
        /// Write config.json
        /// </summary>
        /// <param name="outputPath">Path of config.json</param>
        protected virtual void WriteConfigObject(string outputPath)
        {
            var pluginDirectories = new List <string>();
            var plugins           = new List <string>();
            var pluginRoot        = $"../{Parameters.ProjectName}.Plugins";

            if (string.IsNullOrEmpty(Parameters.UseDefaultPlugins))
            {
                // Not use default plugins
                pluginDirectories.Add(pluginRoot);
                plugins.Add(Parameters.ProjectName);
            }
            else
            {
                // Use default plugins
                var collection = PluginCollection.FromFile(Parameters.UseDefaultPlugins);
                pluginDirectories.Add(pluginRoot);
                pluginDirectories.Add(PathUtils.MakeRelativePath(
                                          Path.GetDirectoryName(Path.GetDirectoryName(outputPath)),
                                          Path.GetDirectoryName(Parameters.UseDefaultPlugins)));
                plugins.AddRange(collection.PrependPlugins);
                plugins.Add(Parameters.ProjectName);
                plugins.AddRange(collection.AppendPlugins);
            }
            var json = JsonConvert.SerializeObject(new {
                ORM               = Parameters.ORM,
                Database          = Parameters.Database,
                ConnectionString  = Parameters.ConnectionString,
                PluginDirectories = pluginDirectories,
                Plugins           = plugins
            }, Formatting.Indented);

            Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            File.WriteAllText(outputPath, json, Encoding.UTF8);
        }
        }//Scanner

        #endregion private

        #region creator

        private Channel(ComunicationNet.ChannelsRow myCDsc, CommServerComponent parent, bool demoVersion, ISettingsBase settings)
            : base(false, "ChannelSegTOL_" + myCDsc.Name)
        {
            CommServerComponent.Tracer.TraceVerbose(150, m_src, "Creating channel: " + myCDsc.Name);
            Multichannel.NextChannnel();
            myStatistics = new Statistics.ChannelStatistics(myCDsc);
            PluginCollection m_Plugins = new PluginCollection(parent.m_CommonBusControl);

            foreach (ComunicationNet.ProtocolRow proto in myCDsc.GetProtocolRows())
            {
                IApplicationLayerMaster chnProtocol = CreateApplicationProtocol(proto, parent, m_Plugins, settings);
                if (chnProtocol != null)
                {
                    foreach (ComunicationNet.SegmentsRow currDSC in proto.GetSegmentsRows())
                    {
                        SegmentParameters  parameters       = new SegmentParameters(currDSC);
                        Diagnostic.Segment segmentStatistic = new Diagnostic.Segment(currDSC, myStatistics);
                        Segment            segment          = new Segment
                                                                  (currDSC, (byte)proto.MaxNumberOfRetries, chnProtocol, parameters, demoVersion, segmentStatistic, this)
                        {
                            Cycle = parameters.TimeReconnect
                        };
                        segment.ResetCounter();
                    }
                }
                else
                {
                    string name = proto != null ? proto.Name : "---not set---";
                    CommServerComponent.Tracer.TraceWarning(199, m_src, "Cannot find component implementing the required protocol: " + name);
                }
            } //foreach (NetworkConfig.ComunicationNet.ProtocolRow proto in myCDsc.GetProtocolRows)
            CommServerComponent.Tracer.TraceVerbose(203, m_src, "Channel: " + myCDsc.Name + " has been created.");
        }     //Channel
Example #11
0
        /// <summary>
        ///初始化界面
        /// </summary>
        private void InitialFrm()
        {
            _frmTemp.SysInfo = "获取系统功能插件中...";
            _frmTemp.RefreshLable();
            //从插件文件夹中获取插件接口对象
            PluginHandle     pluginHandle = new PluginHandle(Mod.m_PluginFolderPath);
            PluginCollection pluginCol    = pluginHandle.GetPluginFromDLL();

            //初始化主框架对象
            Mod.v_AppForm = new Fan.Plugin.Application.AppForm(this, pluginCol);
            //分类解析、获取插件
            m_MainPluginUI.IntialModuleCommon(Mod.m_LoginUser, pluginCol);
            //根据用户权限价值窗体
            string strMessage = m_MainPluginUI.LoadForm(Mod.v_AppForm as Fan.Plugin.Application.IApplicationRef);

            if (!string.IsNullOrEmpty(strMessage))
            {
                LogManage.WriteLog(strMessage);
            }
            SysLogInfoChangedEvent newEvent = new SysLogInfoChangedEvent("加载数据...");

            SysLogInfoChnaged(null, newEvent);
            //根据XML加载插件界面
            m_MainPluginUI.LoadData(Mod.v_AppForm as Fan.Plugin.Application.IApplicationRef);
        }
Example #12
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainGIS_Load(object sender, EventArgs e)
        {
            //从插件文件夹中获得实现插件接口的对象
            PluginCollection pluginCol = PluginHandle.GetPluginsFromDll();
            //解析这些插件对象,获得不同类型的插件集合
            ParsePluginCollection parsePluhinCol = new ParsePluginCollection();

            parsePluhinCol.GetPluginArray(pluginCol);
            _CommandCol        = parsePluhinCol.GetCommands;
            _ToolCol           = parsePluhinCol.GetTools;
            _ToolBarCol        = parsePluhinCol.GetToolBarDefs;
            _MenuItemCol       = parsePluhinCol.GetMenuDefs;
            _DockableWindowCol = parsePluhinCol.GetDockableWindows;

            //获得Command和Tool在UI层上的Category属性,只是纯粹的分类符号
            //可以根据不同类别插件进行UI级解析,可以编写 为uicommon uitool
            //foreach (string categoryName in parsePluhinCol.GetCommandCategorys)
            //{
            //    //对ui进行分为不同的类别
            //    //uiCommandManager.Categories.Add(new UICommandCategory(categoryName));
            //}
            //产生UI对象
            CreateUICommandTool(_CommandCol, _ToolCol);
            CreateToolBars(_ToolBarCol);
            CreateMenus(_MenuItemCol);
            CreateDockableWindow(_DockableWindowCol);
            //保证宿主程序启动后不存在任何默认的处于使用状态的ITool对象
            _mapControl.CurrentTool        = null;
            _pageLayoutControl.CurrentTool = null;
        }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AvailableDPTree"/> class.
 /// </summary>
 /// <param name="pParent">The parent CommonBusControl.</param>
 /// <param name="pOKCnacelForm">The reference to parent form with interface ICanBeAccepted.</param>
 public AvailableDPTree(CommonBusControl pParent, ICanBeAccepted pOKCnacelForm)
     : this()
 {
     m_OKCnacelForm = pOKCnacelForm;
     //m_OKCnacelForm.SetUserControl = this;
     m_PluginCollection = new PluginCollection(pParent);
     FillTree(m_PluginCollection);
 }
Example #14
0
        internal static void Reset()
        {
            _domainPlugins = new PluginCollection();
            _uiPlugins     = new PluginCollection();
            _allPlugins    = null;

            ResetLocation();
        }
Example #15
0
        internal static void Reset()
        {
            _allPluginsLoaded = false;
            _domainPlugins    = new PluginCollection();
            _uiPlugins        = new PluginCollection();
            _allPlugins       = new PluginCollection();

            ResetLocation();
        }
Example #16
0
        public AddonForm(PluginCollection addons)
        {
            InitializeComponent();

               //_addons = AddonLoader.LoadAddons(Application.StartupPath + "\\Addons");
            _addons = addons;

            listAddons.DataSource = _addons;
            listAddons.DisplayMember = "AddonName";
        }
Example #17
0
 private static void showPlugin(PluginCollection cec)
 {
     foreach(var ce in cec)
     {
         var pe = ce as PluginElement;
         Console.WriteLine("=============================");
         Console.WriteLine($"plugin: {pe.AssemblyName}");
         showParam(pe.Params);
     }
 }
Example #18
0
        public AddonForm(PluginCollection addons)
        {
            InitializeComponent();

            //_addons = AddonLoader.LoadAddons(Application.StartupPath + "\\Addons");
            _addons = addons;

            listAddons.DataSource    = _addons;
            listAddons.DisplayMember = "AddonName";
        }
        public static PluginElement GetPluginConfig(string name)
        {
            PluginCollection plugins = GetPlugins();

            if (plugins != null)
            {
                return(plugins[name]);
            }
            return(null);
        }
        public void Should_Create_Pipeline()
        {
            var container = new TinyIoCContainer();
            container.Register<ILogger>(new DoNothingLogger());

            var plugins = new PluginCollection<BundleImpl>();
            var pipeline = task.CreatePipeline<BundlePipelineImpl>(container, plugins);

            Assert.IsInstanceOf<BundlePipelineImpl>(pipeline);
        }
Example #21
0
 public AdminPanelSettings()
 {
     _Plugins         = new PluginCollection();
     _User            = string.Empty;
     _Pass            = string.Empty;
     _Host            = string.Empty;
     _Port            = string.Empty;
     _LicenseKey      = string.Empty;
     _AdvancedOptions = false;
     _Loaded          = false;
 }
Example #22
0
        internal static void LockPlugins()
        {
            //所有插件(其中,DomainPlugins 在列表的前面,UIPlugins 在列表的后面。)
            _allPlugins = new PluginCollection();

            //domain plugins.
#if NET45
            var configPlugins = Configuration.Section.DomainPlugins.OfType <PluginElement>().Select(e => e.Plugin).ToArray();
#endif
#if NS2
            var configPlugins = Configuration.Section.DomainPlugins;
#endif
            if (configPlugins != null && configPlugins.Length > 0)
            {
                InitPluginsByConfig(_domainPlugins, configPlugins);
            }
            _domainPlugins.Insert(0, new Rafy.Domain.RafyDomainPlugin());
            _domainPlugins.Lock();

            foreach (var item in _domainPlugins)
            {
                _allPlugins.Add(item);
            }

            //ui plugins.
            if (_location.IsUI)
            {
#if NET45
                configPlugins = Configuration.Section.UIPlugins.OfType <PluginElement>().Select(e => e.Plugin).ToArray();
#endif
#if NS2
                configPlugins = Configuration.Section.UIPlugins;
#endif
                if (configPlugins != null && configPlugins.Length > 0)
                {
                    InitPluginsByConfig(_uiPlugins, configPlugins);
                }
                if (_location.IsWPFUI)
                {
                    _uiPlugins.Insert(0, LoadRafyPlugin("Rafy.WPF"));
                }
                _uiPlugins.Lock();

                foreach (var item in _uiPlugins)
                {
                    _allPlugins.Add(item);
                }
            }

            CheckDuplucatePlugins();

            _allPlugins.Lock();
        }
Example #23
0
 /// <summary>
 /// This method loads the custom entity web service layer plugin or the common entity web service if no custom one exists.
 /// </summary>
 /// <returns>The custom or common web service.</returns>
 public TWebService LoadPluginOrCommon()
 {
     if (PluginCollection != null && PluginCollection.Any())
     {
         if (Plugins == null || !Plugins.Any())
         {
             throw new Exception("Custom entity web service plugin found but failed to load.");
         }
         return(Plugins[0]);
     }
     return(new TWebService());
 }
Example #24
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainGIS_Load(object sender, EventArgs e)
        {
            //从插件文件夹中获得实现插件接口的对象
            PluginCollection pluginCol = PluginHandle.GetPluginsFromDll();
            //解析这些插件对象,获得不同类型的插件集合
            ParsePluginCollection parsePluhinCol = new ParsePluginCollection();

            parsePluhinCol.GetPluginArray(pluginCol);
            _CommandCol        = parsePluhinCol.GetCommands;
            _ToolCol           = parsePluhinCol.GetTools;
            _ToolBarCol        = parsePluhinCol.GetToolBarDefs;
            _MenuItemCol       = parsePluhinCol.GetMenuDefs;
            _DockableWindowCol = parsePluhinCol.GetDockableWindows;

            //获得Command和Tool在UI层上的Category属性,只是纯粹的分类符号
            //可以根据不同类别插件进行UI级解析,可以编写 为uicommon uitool
            //foreach (string categoryName in parsePluhinCol.GetCommandCategorys)
            //{
            //    //对ui进行分为不同的类别
            //    //uiCommandManager.Categories.Add(new UICommandCategory(categoryName));
            //}
            //产生UI对象
            CreateUICommandTool(_CommandCol, _ToolCol);
            CreateToolBars(_ToolBarCol);
            CreateMenus(_MenuItemCol);
            CreateDockableWindow(_DockableWindowCol);
            //保证宿主程序启动后不存在任何默认的处于使用状态的ITool对象
            _mapControl.CurrentTool        = null;
            _pageLayoutControl.CurrentTool = null;

            //主界面系统名称,获取目录下的SystemName.txt[可灵活设置]
            string sUIName = "县域尺度低丘缓坡山地开发土地优化布局系统";

            string sTxtFileName = System.Windows.Forms.Application.StartupPath + "\\SystemName.txt";

            if (!File.Exists(sTxtFileName))
            {
                this.FindForm().Text = sUIName;
                return;
            }

            StreamReader sr = new StreamReader(sTxtFileName, Encoding.Default);
            String       line;

            while ((line = sr.ReadLine()) != null)
            {
                sUIName = line.ToString();
            }
            //this.Name = sUIName;

            this.FindForm().Text = sUIName;
        }
Example #25
0
 private void LoadPlugins()
 {
     //Retrieve a plugin collection using our custom Configuration section handler
     try
     {
         _plugins = (PluginCollection)ConfigurationManager.GetSection("plugins");
         FillPluginMenu();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #26
0
 /// <summary>
 /// Initializes a new plugin manager.
 /// </summary>
 /// <param name="registry">The registry of plugins.</param>
 /// <param name="baseProvider">The base service provider.</param>
 /// <param name="commandRegister">Command registerer.</param>
 /// <param name="defaultBranchName">The default branch name (typically "develop"). Must not be null or empty.</param>
 public GitPluginManager(GitPluginRegistry registry, ISimpleServiceContainer baseProvider, CommandRegister commandRegister, string defaultBranchName)
 {
     if (String.IsNullOrWhiteSpace(defaultBranchName))
     {
         throw new ArgumentNullException(nameof(defaultBranchName));
     }
     ServiceContainer   = new SimpleServiceContainer(baseProvider);
     _defaultBranchName = defaultBranchName;
     _commandRegister   = commandRegister ?? throw new ArgumentNullException(nameof(commandRegister));
     Registry           = registry;
     _plugins           = new PluginCollection <IGitPlugin>(this, null);
     _branches          = new Branches(this);
 }
Example #27
0
 public void ShowPlugins(PluginCollection plugins)
 {
     foreach (IPlugin plugin in plugins)
     {
         foreach (Extension extension in plugin.Extensions)
         {
             foreach (IModule module in extension.ModulesCollection)
             {
                 listView1.Items.Add(new ListViewItem(new string[] { plugin.Name, plugin.Description, plugin.Version, module.ID, module.Class }));
             }
         }
     }
 }
Example #28
0
        public static PluginCollection SelectAll()
        {
            PluginCollection List = new PluginCollection();

            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblPlugin_Select_SelectAll_hoangda"))
            {
                while (rd.Read())
                {
                    List.Add(getFromReader(rd));
                }
            }
            return(List);
        }
Example #29
0
 private void FillTree(PluginCollection pPlugins)
 {
     foreach (KeyValuePair <Guid, IDataProviderID> dp in pPlugins)
     {
         TreeNode nndp = new TreeNode(dp.Value.Title);
         nndp.Tag = dp.Value;
         c_TreeView.Nodes[0].Nodes.Add(nndp);
         foreach (KeyValuePair <string, ICommunicationLayerId> cl in dp.Value)
         {
             TreeNode nncl = new TreeNode(cl.Value.Title);
             nncl.Tag = cl.Value;
             nndp.Nodes.Add(nncl);
         }
     }
 }
Example #30
0
        /// <summary>
        /// Constructor of the kernel.
        /// </summary>
        public Kernel()
        {
            /* Instantiate forms */
            pluginsForm = new PluginManagerForm();
            aboutForm   = new AboutForm();

            /* Instatiate timers */
            //timer = new Tibia.Util.Timer(3000, false);
            //timer.OnExecute += new Tibia.Util.Timer.TimerExecution(timer_OnExecute);

            /* Plug-in related */
            plugins = new PluginCollection();

            /* Skin related */
            //skin = new Skin(Settings.Default.Skin);
        }
        private static void Main(string[] args)
        {
            List <IPlugin>   plugins = PluginManager.GetExecutePlugin();
            PluginCollection configs = PluginManager.GetPlugins();

            for (int i = 0; i < plugins.Count; i++)
            {
                PluginContext context = PluginManager.GetExecutePluginContext(configs[i].Name);
                context.Config = PluginManager.GetPluginConfig(configs[i].Name);
                Console.WriteLine(configs[i].Name + " running .....");
                plugins[i].Execute(context);
                Console.WriteLine(configs[i].Name + " complete .....");
            }

            Console.WriteLine("complete");
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            string        testStrToLow = "StringToLower plugin test";
            StringToLower strToLow     = new StringToLower();

            testStrToLow = strToLow.Modify(testStrToLow);
            Console.WriteLine(testStrToLow);
            Console.WriteLine();

            string        testStrToUp = "StringToUpper plugin test";
            StringToUpper strToUp     = new StringToUpper();

            testStrToUp = strToUp.Modify(testStrToUp);
            Console.WriteLine(testStrToUp);
            Console.WriteLine();

            PluginCollection <string> plCol = new PluginCollection <string>();

            plCol.Add(strToLow);
            plCol.Add(strToUp);
            string testPlCol = "PluginCollection plugin Test";

            testPlCol = plCol.Modify(testPlCol);
            Console.WriteLine(testPlCol);
            Console.WriteLine();

            string testPlPrint = "PluginPrinter  test";
            PluginPrinter <string> plPrinter = new PluginPrinter <string>(strToLow, testPlPrint);

            plPrinter.Print();
            Console.WriteLine();

            Console.WriteLine("DoublePlugin plugin test");
            double       testDouble = -54.582;
            DoublePlugin doublePl   = new DoublePlugin();

            Console.WriteLine(doublePl.Modify(testDouble));
            Console.WriteLine();

            Console.WriteLine("PluginablePlugin plugin test");
            PluginablePlugin plaginablePl = new PluginablePlugin(doublePl);

            Console.WriteLine(plaginablePl.Modify(testDouble));

            Console.ReadLine();
        }
Example #33
0
        public Manager(CommandLineArguments args)
        {
            mAssemblies     = new List <Assembly>();
            mPlugins        = new PluginCollection();
            mOpenDocuments  = new List <Document>();
            mFileTypes      = new Dictionary <string, Type>();
            mActiveDocument = null;

            mFileWatcher = new FileWatcher();
            mFileWatcher.FileModified          += new FileModifiedEventHandler(FileWatcher_FileModified);
            mFileWatcher.FileAttributesChanged += new FileAttributesChangedEventHandler(FileWatcher_FileAttributesChanged);

            mOptionsManager     = new OptionsManager(this);
            mApplicationOptions = new ApplicationOptions();
            mOptionsManager.Options.Add(mApplicationOptions);

            mAssemblies.Add(Assembly.GetExecutingAssembly());

            mPluginPath = new List <string>();
            string currentDirectory = System.IO.Directory.GetCurrentDirectory();
            string exeDirectory     = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            mPluginPath.Add(currentDirectory);
            if (currentDirectory != exeDirectory)
            {
                mPluginPath.Add(exeDirectory);
            }

            foreach (string path in args.GetValues("--pluginFolder"))
            {
                mPluginPath.Add(path);
            }

            foreach (string path in mPluginPath)
            {
                FindPlugins(path);
            }

            mRegistryRoot = Registry.CurrentUser.OpenSubKey("Software\\Tantalus\\Tilde", true);
            if (mRegistryRoot == null)
            {
                mRegistryRoot = Registry.CurrentUser.CreateSubKey("Software\\Tantalus\\Tilde");
            }

            CreatePlugins();
        }
Example #34
0
        void InitBass()
        {
            // initialize default output device
            if (!Bass.Init())
            {
                MessageBox.Show("Can't initialize device");

                Application.Current.Shutdown();
            }

            // initialize file selector
            _ofd.Filter = "BASS built-in (*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif)|*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif";

            // look for plugins (in the executable's directory)
            foreach (var plugin in Directory.EnumerateFiles(Environment.CurrentDirectory, "bass*.dll"))
            {
                var fileName = Path.GetFileNameWithoutExtension(plugin);

                int hPlugin;

                if ((hPlugin = Bass.PluginLoad(plugin)) == 0)
                {
                    continue;
                }

                // plugin loaded...
                var pinfo = Bass.PluginGetInfo(hPlugin);

                // get plugin info to add to the file selector filter...
                foreach (var format in pinfo.Formats)
                {
                    _ofd.Filter += $"|{format.Name} ({format.FileExtensions}) - {fileName}|{format.FileExtensions}";
                }

                // add plugin to the list
                PluginCollection.Add(fileName);
            }

            _ofd.Filter += "|All Files|*.*";

            if (PluginCollection.Count == 0) // no plugins...
            {
                PluginCollection.Add("no plugins - visit the BASS webpage to get some");
            }
        }
Example #35
0
		public Manager(CommandLineArguments args)
		{
			mAssemblies = new List<Assembly>();
			mPlugins = new PluginCollection();
			mOpenDocuments = new List<Document>();
			mFileTypes = new Dictionary<string, Type>();
			mActiveDocument = null;

			mFileWatcher = new FileWatcher();
			mFileWatcher.FileModified += new FileModifiedEventHandler(FileWatcher_FileModified);
			mFileWatcher.FileAttributesChanged += new FileAttributesChangedEventHandler(FileWatcher_FileAttributesChanged);

			mOptionsManager = new OptionsManager(this);
			mApplicationOptions = new ApplicationOptions();
			mOptionsManager.Options.Add(mApplicationOptions);

			mAssemblies.Add(Assembly.GetExecutingAssembly());

			mPluginPath = new List<string>();
			string currentDirectory = System.IO.Directory.GetCurrentDirectory();
			string exeDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			mPluginPath.Add(currentDirectory);
			if(currentDirectory != exeDirectory)
				mPluginPath.Add(exeDirectory);

			foreach (string path in args.GetValues("--pluginFolder"))
				mPluginPath.Add(path);

			foreach (string path in mPluginPath)
			{
				FindPlugins(path);
			}

			mRegistryRoot = Registry.CurrentUser.OpenSubKey("Software\\Tantalus\\Tilde", true);
			if (mRegistryRoot == null)
				mRegistryRoot = Registry.CurrentUser.CreateSubKey("Software\\Tantalus\\Tilde");

			CreatePlugins();
		}
        static void Main(string[] args)
        {
            string testStrToLow = "StringToLower plugin test";
            StringToLower strToLow = new StringToLower();
            testStrToLow = strToLow.Modify(testStrToLow);
            Console.WriteLine(testStrToLow);
            Console.WriteLine();

            string testStrToUp = "StringToUpper plugin test";
            StringToUpper strToUp = new StringToUpper();
            testStrToUp = strToUp.Modify(testStrToUp);
            Console.WriteLine(testStrToUp);
            Console.WriteLine();

            PluginCollection<string> plCol = new PluginCollection<string>();
            plCol.Add(strToLow);
            plCol.Add(strToUp);
            string testPlCol = "PluginCollection plugin Test";
            testPlCol = plCol.Modify(testPlCol);
            Console.WriteLine(testPlCol);
            Console.WriteLine();

            string testPlPrint = "PluginPrinter  test";
            PluginPrinter<string> plPrinter = new PluginPrinter<string>(strToLow, testPlPrint);
            plPrinter.Print();
            Console.WriteLine();

            Console.WriteLine("DoublePlugin plugin test");
            double testDouble = -54.582;
            DoublePlugin doublePl = new DoublePlugin();
            Console.WriteLine(doublePl.Modify(testDouble));
            Console.WriteLine();

            Console.WriteLine("PluginablePlugin plugin test");
            PluginablePlugin plaginablePl = new PluginablePlugin(doublePl);
            Console.WriteLine(plaginablePl.Modify(testDouble));

            Console.ReadLine();
        }
 public With_TimerEvent_Plugin()
 {
     collection = new PluginCollection<TimerEventPlugin>(new List<TimerEventPlugin> {plugin});
 }
Example #38
0
 public ProgramSettingsData()
 {
     this.plugins = new PluginCollection();
     this.defaultCommands = new FeaturedCommandCollection();
     this.commands = new BindableCollection<ICommand>();
 }
 public OrangeBugRenderer()
 {
     Plugins = new PluginCollection(this);
     ZoomLevel = CurrentZoomLevel;
     CameraPosition = CurrentCameraPosition;
 }
 /// <summary>
 /// 解析插件集合中所有的对象
 /// 将其分别装入ICommand,ITool,IToolBarDef,IMenuDefI和DockableWindowDef 5个集合
 /// </summary>
 /// <param name="pluginCol">插件集合</param>
 public void GetPluginArray(PluginCollection pluginCol)
 {
     //遍历插件集合
     foreach (IPlugin plugin in pluginCol)
     {
         //获得Command接口并添加到Command集合中
         MyPluginEngine.ICommand cmd = plugin as MyPluginEngine.ICommand;
         if (cmd != null)
         {
             this._Commands.Add(cmd.ToString(), cmd);
             //找出该Command的Category,如果它还没有添加到Category则添加
             if (cmd.Category != null && _CommandCategory.Contains(cmd.Category) == false)
             {
                 _CommandCategory.Add(cmd.Category);
             }
             continue;
         }
         //获得ITool接口并添加到ITool集合中
         MyPluginEngine.ITool tool = plugin as MyPluginEngine.ITool;
         if (tool != null)
         {
             this._Tools.Add(tool.ToString(), tool);
             if (tool.Category != null && _CommandCategory.Contains(tool.Category) == false)
             {
                 _CommandCategory.Add(tool.Category);
             }
             continue;
         }
         //获得IToolBarDef接口并添加到IToolBarDef集合中
         MyPluginEngine.IToolBarDef toolbardef = plugin as MyPluginEngine.IToolBarDef;
         if (toolbardef != null)
         {
             this._ToolBars.Add(toolbardef.ToString(), toolbardef);
             continue;
         }
         //获得IMenuDef接口并添加到IMenuDef集合中
         MyPluginEngine.IMenuDef menudef = plugin as MyPluginEngine.IMenuDef;
         if (menudef != null)
         {
             this._Menus.Add(menudef.ToString(), menudef);
             continue;
         }
         //获得IDockableWindowDef接口并添加到IDockableWindowDef集合中
         MyPluginEngine.IDockableWindowDef dockablewindowdef = plugin as MyPluginEngine.IDockableWindowDef;
         if (dockablewindowdef != null)
         {
             this._DockableWindows.Add(dockablewindowdef.ToString(), dockablewindowdef);
             continue;
         }
     }
 }
Example #41
0
 /// <summary>
 /// 获得插件对象
 /// </summary>
 /// <param name="pluginCol">当前插件集合</param>
 /// <param name="_type">插件类型</param>
 private static void getPluginObject(PluginCollection pluginCol, Type _type)
 {
     IPlugin plugin = null;
     try
     {
         //object aa = Activator.CreateInstance(_type);
         //创建一个插件对象实例
         plugin = Activator.CreateInstance(_type) as IPlugin;
     }
     catch
     {
         if (AppLog.log.IsErrorEnabled)
         {
             AppLog.log.Error(_type.FullName + "反射生成对象时发生异常");
         }
     }
     finally
     {
         if (plugin != null)
         {
             //判断该插件是否已经存在插件集合中了,如果不是则加入该对象
             if (!pluginCol.Contains(plugin))
             {
                 pluginCol.Add(plugin);
             }
         }
     }
 }
 protected PluginCollectionTest()
 {
     collection = new PluginCollection<Plugin>(Plugins);
 }
Example #43
0
        /// <summary>
        /// 从DLL中获得插件对象并加入到插件容器
        /// </summary>
        /// <returns></returns>
        public static PluginCollection GetPluginsFromDll()
        {
            //存储插件的容器
            PluginCollection _PluginCol = new PluginCollection();
            //判断是否存在该文件夹,如果不存在则自动创建一个,避免异常
            if (!Directory.Exists(pluginFolder))
            {
                Directory.CreateDirectory(pluginFolder);
                if (AppLog.log.IsDebugEnabled)
                {
                    AppLog.log.Debug("plugin文件夹不存在,系统自带创建一个!");
                }
            }
            //获得插件文件夹中的每一个dll文件
            string[] _files = Directory.GetFiles(pluginFolder, "*.dll");
            foreach (string _file in _files)
            {
                //根据程序集文件名加载程序集
                Assembly _assembly = Assembly.LoadFrom(_file);
                if (_assembly != null)
                {
                    Type[] _types = null;
                    try
                    {
                        //获得程序集中定义的类型
                        _types = _assembly.GetTypes();
                    }
                    catch
                    {
                        if (AppLog.log.IsErrorEnabled)
                        {
                            AppLog.log.Error("反射类型加载异常!");
                        }
                    }
                    finally
                    {
                        foreach (Type _type in _types)
                        {
                            //获得一个类型所有实现的接口
                            Type[] _interfaces = _type.GetInterfaces();
                            //遍历接口类型
                            foreach (Type theInterface in _interfaces)
                            {
                                //如果满足某种类型,则添加到插件集合对象中
                                switch (theInterface.FullName)
                                {
                                    //MyPluginEngine.
                                    case "MyPluginEngine.ICommand":
                                    case "MyPluginEngine.ITool":
                                    case "MyPluginEngine.IMenuDef":
                                    case "MyPluginEngine.IToolBarDef":
                                    case "MyPluginEngine.IDockableWindowDef":
                                        getPluginObject(_PluginCol, _type);
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                    }

                }
            }
            return _PluginCol;
        }
 /// <summary>
 /// 插件容器迭代器构造函数
 /// </summary>
 /// <param name="mappings">插件集合</param>
 public PluginCollectionEnumerator(PluginCollection mappings)
 {
     _temp = (IEnumerable)mappings;
     _enumerator = _temp.GetEnumerator();
 }
Example #45
0
        private void InitialisePlugins()
        {
            // TODO: Spin Up the Plugins Loaded in the Current Directory and "Plugins" Directory.
            var asmCat = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            var container = new CompositionContainer(asmCat);
            container.ComposeParts(this);

            TimerEventPlugins = new PluginCollection<TimerEventPlugin>(TimerEventPluginImports);

            // TODO: Bind the Plugins to the Timer Events.
        }
Example #46
0
 public PluginManager()
 {
     Plugins = new PluginCollection();
 }