コード例 #1
0
 public static void AddPlugins(IEnumerable <IPlugin> plugins)
 {
     if (Plugins != null)
     {
         Plugins.AddRange(plugins);
     }
 }
コード例 #2
0
ファイル: PluginLoader.cs プロジェクト: GabrielTK/DropMeter
 public static void InitializePlugins()
 {
     foreach (var asm in PluginASM)
     {
         Plugins.AddRange(InitializePlugin(asm));
     }
 }
コード例 #3
0
        /// <summary>
        /// Return a copy of the list of plugins.
        /// </summary>
        private Plugins _pluginsCopy()
        {
            Plugins plugins = new Plugins();

            using (this.Lock.read())
            {
                plugins.AddRange(_plugins);
            }
            return(plugins);
        }
コード例 #4
0
 // Checkea si un plugins esta disponible para agregarlos a una lista de instancias
 private void CheckAvaliable()
 {
     if (PluginAssets.Count > 0)
     {
         Plugins.AddRange(
             PluginAssets
             .Instance <IPlugin>()
             .Execute(Configure)
             );
         PluginAssets.Clear();
     }
 }
コード例 #5
0
        public Home AddPlugins(List <Plugin> plugins)
        {
            if (Plugins.IsNullOrEmpty())
            {
                Plugins = new List <Plugin>();
            }

            Plugins.AddRange(plugins);

            foreach (var plugin in plugins)
            {
                AddDomainEvent(new HomeAddPluginEvent(plugin.Name));
            }
            return(this);
        }
コード例 #6
0
        /// <inheritdoc/>
        protected override void InitPlugins()
        {
            base.InitPlugins();
            FMainMenu  = new DesignerMenu(this);
            FStatusBar = new DesignerStatusBar(this);

            FStandardToolbar = new StandardToolbar(this);
            FTextToolbar     = new TextToolbar(this);
            FBorderToolbar   = new BorderToolbar(this);
            FLayoutToolbar   = new LayoutToolbar(this);
            FStyleToolbar    = new StyleToolbar(this);

            //FStandardToolbar.EndDrag += new EventHandler(LayoutChanged);
            //FTextToolbar.EndDrag += new EventHandler(LayoutChanged);
            //FBorderToolbar.EndDrag += new EventHandler(LayoutChanged);
            //FLayoutToolbar.EndDrag += new EventHandler(LayoutChanged);
            //FStyleToolbar.EndDrag += new EventHandler(LayoutChanged);

            // set toolbars position
            DotNetBarManager.ToolbarTopDockSite.Controls.Add(FStandardToolbar);
            FTextToolbar.DockLine = 1;
            DotNetBarManager.ToolbarTopDockSite.Controls.Add(FTextToolbar);
            FBorderToolbar.DockLine = 1;
            DotNetBarManager.ToolbarTopDockSite.Controls.Add(FBorderToolbar);
            FLayoutToolbar.DockLine = 2;
            FLayoutToolbar.Hide();
            DotNetBarManager.ToolbarTopDockSite.Controls.Add(FLayoutToolbar);
            FStyleToolbar.DockLine = 2;
            FStyleToolbar.Hide();
            DotNetBarManager.ToolbarTopDockSite.Controls.Add(FStyleToolbar);

            Plugins.AddRange(new IDesignerPlugin[] {
                FMainMenu, FStatusBar, FStandardToolbar, FTextToolbar, FBorderToolbar,
                FLayoutToolbar, FStyleToolbar
            });

            CreateToolbarMenu();
        }
コード例 #7
0
        /// <summary>
        /// Initializes this instance and all the plugins.
        /// </summary>
        internal static void Initialize()
        {
            Main.Log.AppendLine("Loading plugins.");

            string pluginPath = "";

            {
                var v = Main.Config.GetValue(Main._Config_Plugin_Path);
                if (v != null)
                {
                    pluginPath = v.ToString();
                }
            }

            Main.Log.AppendLine("Path to plugins: \"" + pluginPath + "\".");

            DirectoryInfo dir = new DirectoryInfo(pluginPath);

            if (!dir.Exists)
            {
                Main.Log.AppendLine("Directory \"" + pluginPath + "\" does not exist.");
            }
            else
            {
                Dictionary <string, Plugin> plugins = new Dictionary <string, Plugin>(StringComparer.OrdinalIgnoreCase);
                FileInfo[] files = dir.GetFiles("*.dll", SearchOption.TopDirectoryOnly);
                foreach (var f in files)
                {
                    // Process all files.
                    try
                    {
                        ProcessFile(f, plugins);
                    }
                    catch (Exception e)
                    {
                        Main.Log.Append(e);
                    }
                }

                List <KeyValuePair <string, Plugin> > loadedOrder = new List <KeyValuePair <string, Plugin> >();
                var processing = plugins.ToList();
                foreach (var x in plugins)
                {
                    Plugins.Add(x);
                }

                Main._is_initializing_plugin++;

                bool lastLoaded = true;
                while (processing.Count != 0)
                {
                    bool nowLoaded = false;
                    for (int i = 0; i < processing.Count;)
                    {
                        var p = processing[i];
                        int r;
                        Main._is_initializing_plugin++;
                        try
                        {
                            r = p.Value._initialize(lastLoaded) ? 1 : 0;
                        }
                        catch (FileNotFoundException ex)
                        {
                            r = -1;
                            Main.Log.AppendLine("Exception occurred while trying to initialize plugin " + p.Value.GetInternalString() + ":");
                            Main.Log.Append(ex);
                            if (ex.Message != null && ex.Message.Contains("'NetScriptFramework.Skyrim,"))
                            {
                                //Main.Log.AppendLine("This exception appears to be due to plugin " + p.Value.GetInternalString() + " using old format of the framework! This plugin must be updated before it can be used.");
                                throw new ArgumentException("Plugin " + p.Value.GetInternalString() + " is using old format of framework and must be updated!");
                            }
                            throw;
                        }
                        catch (Exception ex)
                        {
                            r = -1;
                            Main.Log.AppendLine("Exception occurred while trying to initialize plugin " + p.Value.GetInternalString() + ":");
                            Main.Log.Append(ex);
                            throw;
                        }
                        Main._is_initializing_plugin--;
                        if (r > 0)
                        {
                            processing.RemoveAt(i);
                            nowLoaded = true;
                            loadedOrder.Add(p);
                        }
                        else if (r < 0)
                        {
                            processing.RemoveAt(i);
                            nowLoaded = true;
                        }
                        else
                        {
                            i++;
                        }
                    }

                    if (!nowLoaded && !lastLoaded)
                    {
                        StringBuilder str = new StringBuilder();
                        for (int i = 0; i < processing.Count; i++)
                        {
                            if (i > 0)
                            {
                                str.Append(", ");
                            }
                            str.Append(processing[i].Value.GetInternalString());
                        }

                        if (processing.Count == 1)
                        {
                            throw new InvalidOperationException("The following plugin refused to initialize: " + str.ToString());
                        }
                        throw new InvalidOperationException("All the following plugins refused to initialize: " + str.ToString());
                    }

                    lastLoaded = nowLoaded;
                }

                Main._is_initializing_plugin--;

                Plugins.Clear();
                Plugins.AddRange(loadedOrder);
            }

            Main.Log.AppendLine("Finished loading " + Plugins.Count + " plugin" + (Plugins.Count == 1 ? "" : "s") + ".");
        }