Beispiel #1
0
        public virtual void LoadPlugins()
        {
            if (Plugins.Any())
            {
                throw new InvalidOperationException("LoadExtensions()只应调用一次. 刷新应使用RefreshExtensions()");
            }

            //PackageManager.RemovePendingPackagesAndExtensions();

            Thread updateThread = new Thread(AppLoadExtensions);

            updateThread.Start();

            // Update splash screen's progress bar while thread is active.
            //while (updateThread.IsAlive)
            //{
            //    UpdateSplashScreen(_message);
            //}

            updateThread.Join();

            ActivateAllExtensions();
            //OnExtensionsActivated(EventArgs.Empty);

            DataFactory.Default.ProgressHandler = ProgressHandler;
        }
Beispiel #2
0
        private async Task btnPatch_Click(object sender, EventArgs e)
        {
            using var _ = new ControlLock(btnPatch);

            IoC.Notif.ShowStatus("Generating patch...");
            IoC.Notif.ShowUnknownProgress();

            if (Plugins.Any() && !Plugins.All(x => x.ValidateChanges()))
            {
                IoC.Notif.HideProgress();
                IoC.Notif.ShowStatus("Pack install aborted");
                return;
            }

            var sw = new Stopwatch(); sw.Start();

            var success = await Async.Run(CreatePatch);

            Settings.UpdatePatchStatus();

            IoC.Notif.HideProgress();
            if (success)
            {
                IoC.Notif.ShowStatus($"Patch installed ({sw.Elapsed.TotalMilliseconds:n0} ms)");
            }
        }
        public void LoadPlugins(string pluginPath)
        {
            if (!Directory.Exists(pluginPath))
            {
                return;
            }
            if (Plugins.Any())
            {
                UnloadPlugins();
            }
            var files = Directory.GetFiles(pluginPath);

            foreach (var file in files)
            {
                var fileInfo = new FileInfo(file);

                if (fileInfo.Extension.Equals(".dll"))
                {
                    var plugins = GetModule(file, typeof(IPlugin));
                    foreach (var p in plugins)
                    {
                        Plugins.Add(p);
                    }
                }
            }
            Logger.WriteLine("Loading Plugins...", "PluginManager");
            LoadPluginSettings();
        }
            public override void Configure(Container container)
            {
#if NETCORE
                ServiceStack.Memory.NetCoreMemory.Configure();
#endif

                if (!Plugins.Any(x => x is SpanFormats)) //Registered by default
                {
                    Plugins.Add(new SpanFormats());
                }
            }
Beispiel #5
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());
 }
Beispiel #6
0
        /// <summary>
        /// Add a generic plugin.
        /// </summary>
        /// <param name="plugin">The plugin to add.</param>
        public EngineBuilder AddGenericPlugin(Plugin plugin)
        {
            // Check if a plugin of this type already exists.
            if (Plugins.Any(x => x.GetType() == plugin.GetType()))
            {
                return(this);
            }

            // Add the plugin.
            Plugins.Add(plugin);

            return(this);
        }
        private void RemoveRemovedPlugins()
        {
            var settings = UIAssistantAPI.Instance.UIAssistantSettings;

            var oldDisabledPlugins = new HashSet <string>(settings.DisabledPlugins);

            oldDisabledPlugins.ForEach(x =>
            {
                if (!Plugins.Any(y => y.Metadata.Guid.EqualsWithCaseIgnored(x)))
                {
                    settings.DisabledPlugins.Remove(x);
                }
            });
        }
        public void LoadPlugins(string pluginPath, bool checkSubDirs)
        {
            if (!Directory.Exists(pluginPath))
            {
                return;
            }
            if (Plugins.Any())
            {
                UnloadPlugins();
            }
            var dirInfo = new DirectoryInfo(pluginPath);

            var files = dirInfo.GetFiles().Select(f => f.FullName).ToList();

            if (checkSubDirs)
            {
                foreach (var dir in dirInfo.GetDirectories())
                {
                    files.AddRange(dir.GetFiles().Select(f => f.FullName));
                }
            }

            foreach (var file in files)
            {
                var fileInfo = new FileInfo(file);

                if (fileInfo.Extension.Equals(".dll"))
                {
                    var plugins = GetModule(file, typeof(IPlugin));
                    foreach (var p in plugins)
                    {
                        Plugins.Add(p);
                    }
                }
            }
            Logger.WriteLine("Loading Plugins...", "PluginManager");
            LoadPluginSettings();
        }
Beispiel #9
0
 /// <summary>
 /// Check if an assembly is loaded.
 /// </summary>
 /// <param name="path">The path to check from.</param>
 /// <returns>Returns whether the assembly is loaded or not.</returns>
 public static bool IsAssemblyLoaded(string path) => Plugins.Any(plugin => plugin.Assembly.Location == path);
Beispiel #10
0
 /// <summary>Back to the list button. This button is displayed after a fail Install or Uninstall.</summary>
 public void BackToTheList()
 {
     Status = Plugins?.Any() ?? false
 ? PluginManagerStatus.Display
 : PluginManagerStatus.Error;
 }
Beispiel #11
0
        private void SaveSettings()
        {
            if (EnableWindowsIntegration)
            {
                ShellRegister("Directory");
                ShellRegister("Drive");
                ShellRegister("*");
                ShellRegister("here");
            }
            else
            {
                ShellUnregister("Directory");
                ShellUnregister("Drive");
                ShellUnregister("*");
                ShellUnregister("here");
            }

            if (EnableStartupAcceleration)
            {
                StartupRegister();
            }
            else
            {
                StartupUnregister();
            }

            ApplicationFontFamily = EditApplicationFontFamily;
            MainFormFontSize      = EditMainFormFontSize;
            ReplaceFormFontSize   = EditReplaceFormFontSize;
            DialogFontSize        = EditDialogFontSize;

            Settings.Set(GrepSettings.Key.EnableUpdateChecking, EnableCheckForUpdates);
            Settings.Set(GrepSettings.Key.UpdateCheckInterval, CheckForUpdatesInterval);
            Settings.Set(GrepSettings.Key.CustomEditor, CustomEditorPath);
            Settings.Set(GrepSettings.Key.CustomEditorArgs, CustomEditorArgs);
            Settings.Set(GrepSettings.Key.CompareApplication, CompareApplicationPath);
            Settings.Set(GrepSettings.Key.CompareApplicationArgs, CompareApplicationArgs);
            Settings.Set(GrepSettings.Key.ShowFilePathInResults, ShowFilePathInResults);
            Settings.Set(GrepSettings.Key.AllowSearchingForFileNamePattern, AllowSearchWithEmptyPattern);
            Settings.Set(GrepSettings.Key.DetectEncodingForFileNamePattern, DetectEncodingForFileNamePattern);
            Settings.Set(GrepSettings.Key.ExpandResults, AutoExpandSearchTree);
            Settings.Set(GrepSettings.Key.ShowVerboseMatchCount, ShowVerboseMatchCount);
            Settings.Set(GrepSettings.Key.ShowFileInfoTooltips, ShowFileInfoTooltips);
            Settings.Set(GrepSettings.Key.MatchTimeout, MatchTimeout);
            Settings.Set(GrepSettings.Key.FuzzyMatchThreshold, MatchThreshold);
            Settings.Set(GrepSettings.Key.ShowLinesInContext, ShowLinesInContext);
            Settings.Set(GrepSettings.Key.ContextLinesBefore, ContextLinesBefore);
            Settings.Set(GrepSettings.Key.ContextLinesAfter, ContextLinesAfter);
            Settings.Set(GrepSettings.Key.MaxSearchBookmarks, MaxSearchBookmarks);
            Settings.Set(GrepSettings.Key.MaxPathBookmarks, MaxPathBookmarks);
            Settings.Set(GrepSettings.Key.MaxExtensionBookmarks, MaxExtensionBookmarks);
            Settings.Set(GrepSettings.Key.OptionsOnMainPanel, OptionsLocation == PanelSelection.MainPanel);
            Settings.Set(GrepSettings.Key.FollowWindowsTheme, FollowWindowsTheme);
            Settings.Set(GrepSettings.Key.CurrentTheme, CurrentTheme);
            Settings.Set(GrepSettings.Key.UseDefaultFont, UseDefaultFont);
            Settings.Set(GrepSettings.Key.ApplicationFontFamily, ApplicationFontFamily);
            Settings.Set(GrepSettings.Key.MainFormFontSize, MainFormFontSize);
            Settings.Set(GrepSettings.Key.ReplaceFormFontSize, ReplaceFormFontSize);
            Settings.Set(GrepSettings.Key.DialogFontSize, DialogFontSize);
            Settings.Set(GrepSettings.Key.PdfToTextOptions, PdfToTextOptions);

            if (ArchiveOptions.IsChanged)
            {
                string nameKey = "Archive";
                string addKey  = "Add" + nameKey + "Extensions";
                string remKey  = "Rem" + nameKey + "Extensions";

                Settings.Set(addKey, CleanExtensions(ArchiveOptions.AddExtensions));
                Settings.Set(remKey, CleanExtensions(ArchiveOptions.RemExtensions));

                ArchiveOptions.SetUnchanged();
                ArchiveDirectory.Reinitialize();
            }

            bool pluginsChanged = Plugins.Any(p => p.IsChanged);

            foreach (var plugin in Plugins)
            {
                string nameKey    = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(plugin.Name);
                string enabledkey = nameKey + "Enabled";
                string addKey     = "Add" + nameKey + "Extensions";
                string remKey     = "Rem" + nameKey + "Extensions";

                Settings.Set(enabledkey, plugin.IsEnabled);
                Settings.Set(addKey, CleanExtensions(plugin.AddExtensions));
                Settings.Set(remKey, CleanExtensions(plugin.RemExtensions));

                plugin.SetUnchanged();
            }

            Settings.Save();

            if (pluginsChanged)
            {
                GrepEngineFactory.ReloadPlugins();
            }
        }
Beispiel #12
0
        internal protected virtual void SaveToElement(PomXmlElement element)
        {
            //writing modules
            var modulesNode = element.ReadOrCreateElement("modules");

            if (!Modules.Any())
            {
                modulesNode.Remove();
            }
            else
            {
                modulesNode.RemoveAllChildElements();
                foreach (Module module in Modules)
                {
                    if (!string.IsNullOrEmpty(module.Path))
                    {
                        var moduleNode = modulesNode.CreateElement("module");
                        module.SaveTo(moduleNode);
                    }
                }
            }

            //writing dependencies
            var dependenciesNode = element.ReadOrCreateElement("dependencies");

            if (!Dependencies.Any())
            {
                dependenciesNode.Remove();
            }
            else
            {
                dependenciesNode.RemoveAllChildElements();
                foreach (Dependency dependency in Dependencies)
                {
                    var dependencyNode = dependenciesNode.CreateElement("dependency");
                    dependency.SaveToElement(dependencyNode);
                }
            }

            //writing properties
            var propertiesNode = element.ReadOrCreateElement("properties");

            if (!Properties.Any())
            {
                propertiesNode.Remove();
            }
            else
            {
                propertiesNode.RemoveAllChildElements();
                foreach (Property prop in Properties)
                {
                    prop.SaveTo(propertiesNode);
                }
            }

            var buildNode = element.ReadOrCreateElement("build");

            if (!Plugins.Any() && !PluginManagement.Any())             // empty build section
            {
                buildNode.Remove();
            }
            else
            {
                var pluginsNode = buildNode.ReadOrCreateElement("plugins");
                if (!Plugins.Any())
                {
                    pluginsNode.Remove();
                }
                else
                {
                    pluginsNode.RemoveAllChildElements();
                    foreach (Plugin plugin in Plugins)
                    {
                        var pluginNode = pluginsNode.CreateElement("plugin");
                        plugin.SaveToElement(pluginNode);
                    }
                }

                var pluginManagementNode        = buildNode.ReadOrCreateElement("pluginManagement");
                var pluginManagementPluginsNode = pluginManagementNode.ReadOrCreateElement("plugins");

                if (!PluginManagement.Any())
                {
                    pluginManagementNode.Remove();
                }
                else
                {
                    pluginManagementPluginsNode.RemoveAllChildElements();
                    foreach (Plugin plugin in PluginManagement)
                    {
                        var pluginNode = pluginManagementPluginsNode.CreateElement("plugin");
                        plugin.SaveToElement(pluginNode);
                    }
                }
            }
        }
 /// <summary>Back to the list button. This button is displayed after a fail Install or Uninstall.</summary>
 protected virtual void BackToTheList()
 {
     Status = Plugins?.Any() ?? false
 ? PluginManagerStatus.Display
 : PluginManagerStatus.Error;
 }
 private static bool IsCallingMethod(string line, string op)
 {
     return(Plugins.Any(itm => line.StartsWith($"{itm.Alias}{op}")));
 }