コード例 #1
0
        protected void AddDisabledPlugin(string folder)
        {
            NotLoadedPlugin plugin = new NotLoadedPlugin();
            plugin.FriendlyName = FileManager.RemovePath(folder);
            if(plugin.FriendlyName.EndsWith("/") || plugin.FriendlyName.EndsWith("\\"))
            {
                plugin.FriendlyName = plugin.FriendlyName.Substring(0, plugin.FriendlyName.Length - 1);
            }

            PluginContainer container = new PluginContainer(plugin);

            container.AssemblyLocation = folder + "/unknown.dll";

            mPluginContainers.Add(plugin, container);
            container.IsEnabled = false;

            // don't do any startup or anything
        }
コード例 #2
0
        private bool IsLoadedOnStartup(PluginContainer container)
        {
            #if GLUE


            var plugin = SelectedPlugin.Plugin;

            if (plugin is NotLoadedPlugin)
            {
                var loadedState = (plugin as NotLoadedPlugin).LoadedState;

                if(loadedState == LoadedState.NotLoaded)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                string pluginFolder = FileManager.GetDirectory(SelectedPlugin.AssemblyLocation);

                return GlueState.Self.CurrentPluginSettings.PluginsToIgnore.Contains(pluginFolder) == false;
            }
            #else
            return true;
            #endif
        }
コード例 #3
0
        protected void StartupPlugin(IPlugin plugin)
        {
            // See if the plugin already exists - it may implement multiple interfaces
            if (!mPluginContainers.ContainsKey(plugin))
            {
                PluginContainer pluginContainer = new PluginContainer(plugin);
                mPluginContainers.Add(plugin, pluginContainer);

                try
                {
                    plugin.StartUp();
                }
                catch (Exception e)
                {
                    pluginContainer.Fail(e, "Plugin failed in StartUp");
                }
            }
        }
コード例 #4
0
        private static string GetInfoForContainer(PluginContainer container)
        {
            if (container == null)
            {
                return null;
            }
            else if(container.Plugin is NotLoadedPlugin)
            {
                string text = "This plugin is not loaded.\n";

                var asNotLoadedPlugin = container.Plugin as NotLoadedPlugin;

                if(asNotLoadedPlugin.LoadedState == LoadedState.NotLoaded)
                {
                    text += "Plugin is disabled.";
                }
                else
                {
                    text += "Plugin will be loaded next time Glue is started.";
                }

                return text;
            }
            else
            {
                string text = "Version: " + container.Plugin.Version + "\n";

                string fileName = container.AssemblyLocation;
                if (System.IO.File.Exists(fileName))
                {
                    text += "Created: " + System.IO.File.GetCreationTime(fileName).ToShortDateString() + "\n";

                    text += "Location: " + fileName + "\n";
                }

                if (container != null && container.FailureException != null)
                {
                    text += container.FailureException.ToString();

                }
                return text;
            }
        }
コード例 #5
0
        private RssItem GetItemFor(AllFeed feed, PluginContainer SelectedPlugin)
        {
            string folder = 
                FileManager.RemovePath(
                 FileManager.GetDirectory(SelectedPlugin.AssemblyLocation));
            folder = folder.Replace("/", "");
            if (!folder.ToLowerInvariant().EndsWith("plugin"))
            {
                folder += "plugin";
            }
            folder = folder.ToLower();

            RssItem itemToReturn = null;
                
            string whatToLookFor = folder + ".plug";

            // We're going to narrow things down a bit here:
            whatToLookFor = ">" + whatToLookFor + @"</a>";
            
            foreach (var item in feed.Items)
            {
                var description = item.Description.ToLower();

                if (description.Contains(whatToLookFor))
                {
                    itemToReturn = item;
                    break;
                }
            }

            return itemToReturn;
        }
コード例 #6
0
ファイル: PluginManager.cs プロジェクト: vchelaru/FlatRedBall
 private static void PluginCommandWithThrow(Action action, PluginContainer container, string message)
 {
     if (HandleExceptions)
     {
         try
         {
             action();
         }
         catch (Exception e)
         {
             container.Fail(e, message);
             throw;
         }
     }
     else
     {
         action();
     }
 }
コード例 #7
0
ファイル: PluginManager.cs プロジェクト: vchelaru/FlatRedBall
        private static bool WasExceptionCausedByPlugin(Exception exception, PluginContainer plugin)
        {
            if(plugin.Plugin.GetType().Assembly.GetName().Name == exception.Source)
            {
                return true;
            }

            foreach (var name in plugin.Plugin.GetType().Assembly.GetReferencedAssemblies())
            {
                if (name.Name == exception.Source)
                {
                    return true;
                }
            }

            return false;
        }
コード例 #8
0
ファイル: PluginManager.cs プロジェクト: vchelaru/FlatRedBall
        private static void PluginCommand(Action action, PluginContainer container, string message)
        {
            if (HandleExceptions)
            {
                if (mMenuStrip.IsDisposed)
                {
                    try
                    {
                        action();
                    }
                    catch (Exception e)
                    {
                        container.Fail(e, message);

                        ReceiveError(message + "\n" + e.ToString());


                    }
                }
                else
                {
                    if (mMenuStrip.IsDisposed == false)
                    {
                        // Do this on a UI thread
                        mMenuStrip.Invoke((MethodInvoker)delegate
                        {
                            try
                            {
                                action();
                            }
                            catch (Exception e)
                            {
                                container.Fail(e, message);

                                ReceiveError(message + "\n" + e.ToString());


                            }
                        });
                    }
                    else
                    {
                        try
                        {
                            action();
                        }
                        catch (Exception e)
                        {
                            container.Fail(e, message);

                            ReceiveError(message + "\n" + e.ToString());


                        }
                    }
                }
            }
            else
            {
                action();
            }
        }
コード例 #9
0
ファイル: PluginManager.cs プロジェクト: vchelaru/FlatRedBall
        private static void PluginCommandNotUiThread(Action action, PluginContainer container, string message)
        {
            if (HandleExceptions)
            {
                try
                {
                    action();
                }
                catch (Exception e)
                {
                    container.Fail(e, message);

                    ReceiveError(message + "\n" + e.ToString());
                }
            }
            else
            {
                action();
            }
        }
コード例 #10
0
ファイル: PluginsWindow.cs プロジェクト: vchelaru/FlatRedBall
        private bool IsRequiredByProject(PluginContainer selectedPlugin)
        {
            string nameToSearchFor = selectedPlugin.Name;

            return GlueState.Self.CurrentGlueProject.PluginData.RequiredPlugins.Contains(nameToSearchFor);
        }
コード例 #11
0
ファイル: PluginsWindow.cs プロジェクト: vchelaru/FlatRedBall
        private void RespondToRequiredByProject(PluginContainer pluginContainer, bool requiredByProject)
        {
            var name = pluginContainer.Name;

            var requiredPlugins = GlueState.Self.CurrentGlueProject.PluginData.RequiredPlugins;

            bool shouldSave = false;

            if(requiredByProject && requiredPlugins.Contains(name) == false)
            {
                requiredPlugins.Add(name);
                shouldSave = true;
            }
            else if(requiredByProject == false && requiredPlugins.Contains(name))
            {
                requiredPlugins.Remove(name);
                shouldSave = true;
            }

            if(shouldSave)
            {
                TaskManager.Self.AddAsyncTask(
                    ()=>GlueCommands.Self.GluxCommands.SaveGlux(),
                    "Saving project after changing plugin requirements");
            }
        }
コード例 #12
0
ファイル: PluginsWindow.cs プロジェクト: vchelaru/FlatRedBall
        private void RespondToLoadOnStartupChange(PluginContainer pluginContainer, bool shouldBeLoaded)
        {
            string pluginFolder = FileManager.GetDirectory(SelectedPlugin.AssemblyLocation);

#if GLUE
            var pluginSettings = GlueState.Self.CurrentPluginSettings;
            bool shouldSave = false;
            if (shouldBeLoaded && !IsLoadedOnStartup(pluginContainer))
            {
                pluginSettings.PluginsToIgnore.Remove(pluginFolder);

                if (pluginContainer.Plugin is NotLoadedPlugin)
                {
                    (pluginContainer.Plugin as NotLoadedPlugin).LoadedState = LoadedState.LoadedNextTime;
                }

                shouldSave = true;
            }
            else if (!shouldBeLoaded && IsLoadedOnStartup(pluginContainer))
            {
                pluginSettings.PluginsToIgnore.Add(pluginFolder);

                if (pluginContainer.Plugin is NotLoadedPlugin)
                {
                    (pluginContainer.Plugin as NotLoadedPlugin).LoadedState = LoadedState.NotLoaded;
                }

                shouldSave = true;
            }
            if (shouldSave)
            {
                GlueState.Self.CurrentPluginSettings.Save(FileManager.GetDirectory(ProjectManager.GlueProjectFileName));
            }
#endif
        }