public void AddPlugin(IPlugin toAdd) { // Disallow duplicate plugins if (Plugins.Contains(toAdd)) { return; } // Don't add plugin if it fails to load if (!toAdd.TryLoad()) { return; } var plugins = AppSettings.GetOrDefault("plugins", new EmptyPlugin[0]); var match = plugins.FirstOrDefault(p => p.Meta.Name.Equals(toAdd.Meta.Name)); if (match != default) { toAdd.UserSettings = match.UserSettings; } Plugins.Add(toAdd); // Ensure order of plugin execution is correct Plugins.Sort(); Listeners.ForEach(listener => listener.PluginChange_Added(this, toAdd, null)); }
public void AddPlugin(IPlugin plugin) { var prevSettings = AppSettings.GetListAs <PluginMeta>("plugins"); // Disallow duplicate plugins if (Plugins.Contains(plugin)) { return; } // Don't add plugin if it fails to load if (!plugin.TryLoad()) { return; } var pluginName = plugin.Meta.Name; if (prevSettings.Any(m => m.Name.Equals(pluginName))) { plugin.Meta = prevSettings.First(m => m.Name.Equals(pluginName)); } Plugins.Add(plugin); // Ensure order of plugin execution is correct Plugins.Sort(); Listeners.ForEach(listener => listener.PluginChange_Added(this, plugin, null)); }
private void ReIgnite(object sender, System.ComponentModel.CancelEventArgs e) { bool needsToExtinguish = false; foreach (string assembly in Directory.GetFiles("Plugins", "*.dll", SearchOption.TopDirectoryOnly)) { Assembly plugin = Assembly.LoadFrom(assembly); // Get the type to use. var results = from type in plugin.GetTypes() where typeof(IFlameable).IsAssignableFrom(type) select type; foreach (Type type in results) { IFlameable flamable = Activator.CreateInstance(type) as IFlameable; if (!Plugins.Contains(flamable, new FlamableComparer())) { needsToExtinguish = true; } } } if (needsToExtinguish) { Extinguish(); Ignite(); } }
/// <summary> /// Adds a new plugin. If the plugin was already added, nothing will happen. /// </summary> /// <param name="plugin"></param> public void Add(IPlugin plugin) { if (!Plugins.Contains(plugin)) { _plugins.Add(plugin); } }
public void Unregister(TPlugin plugin) { if (Plugins.Contains(plugin)) { plugin.OnUnplug(); Plugins.Remove(plugin); } }
public void RemovePlugin(IPlugin plugin) { if (Plugins.Contains(plugin)) { plugin.Unload(); Plugins.Remove(plugin); Listeners.ForEach(listener => listener.PluginChange_Removed(this, plugin, null)); } }
/// <summary> /// Adds a plugin to this context. /// </summary> /// <param name="plugin">Plugin to add to this context</param> public void AddPlugin(IPlugin plugin) { if (!Plugins.Contains(plugin)) { Plugins.Add(plugin); } OnPropertyChanged("Plugins"); OnPropertyChanged("HasPlugins"); }
private void ResetSearchFilter() { Plugins.Clear(); foreach (var plugin in PluginsSource) { if (!Plugins.Contains(plugin)) { Plugins.Add(plugin); } } }
private void SearchPlugins(string SearchQueryString) { foreach (var plugin in Plugins.Where(p => !p.Name.Contains(SearchQueryString, StringComparison.OrdinalIgnoreCase) && !p.Author.Contains(SearchQueryString, StringComparison.OrdinalIgnoreCase))) { Plugins.Remove(plugin); } foreach (var plugin in Plugins.Where(p => p.Name.Contains(SearchQueryString, StringComparison.OrdinalIgnoreCase) || p.Author.Contains(SearchQueryString, StringComparison.OrdinalIgnoreCase))) { if (!Plugins.Contains(plugin)) { Plugins.Add(plugin); } } }
/// <summary> /// Unloads a plugin and removes all its references in the data and file id dictionaries. /// </summary> /// <param name="plugin">The plugin to unload.</param> private static void UnloadPlugin(IPlugin plugin) //TODO: Find a way to safely unload the AppDomain. { if (Plugins.Contains(plugin)) { Plugins.Remove(plugin); } var dataPlugin = plugin as IDataPlugin; if (dataPlugin != null) { foreach (var dataPluginListKey in DataPlugins.Keys.ToArray()) { var dataPluginList = DataPlugins[dataPluginListKey]; if (dataPluginList.Contains(dataPlugin)) { dataPluginList.Remove(dataPlugin); } if (dataPluginList.Count == 0) { DataPlugins.Remove(dataPluginListKey); } } } var filePlugin = plugin as IFilePlugin; if (filePlugin != null) { foreach (var filePluginListKey in FilePlugins.Keys.ToArray()) { var filePluginList = FilePlugins[filePluginListKey]; if (filePluginList.Contains(filePlugin)) { filePluginList.Remove(filePlugin); } if (filePluginList.Count == 0) { FilePlugins.Remove(filePluginListKey); } } } }
internal void UnloadPlugin(LocalizerPlugin plugin) { if (plugin is null) { Utils.LogWarn($"Plugin cannot be unloaded because it's null"); return; } if (Plugins.Contains(plugin)) { Utils.LogWarn($"Plugin [{plugin.Name}] doesn't exist"); return; } plugin.Dispose(); Plugins.Remove(plugin); Utils.LogInfo($"Plugin [{plugin.Name}] successfully unloaded."); }
public async Task AddPlugin(IPlugin @new) { // Ensure plugin hasn't been added and that it was able to load if (Plugins.Contains(@new) || !await @new.TryLoad()) { return; } var plugins = AppSettings.GetOrDefault("plugins", Array.Empty <EmptyPlugin>()); var match = plugins.FirstOrDefault(p => p.Meta.Name.Equals(@new.Meta.Name)); if (match != null) { @new.UserSettings = match.UserSettings; @new.Meta.Enabled = match.Meta.Enabled; } // Ensure order of plugin execution is correct Plugins.Add(@new); Plugins.Sort(); Listeners.ForEach(listener => listener.PluginChange_Added(this, @new, null)); }
private void SetupScripts() { if (BasePath.Contains("tiny_mce")) { this.Page.ClientScript.RegisterClientScriptBlock( this.GetType(), "tinymcemain", "<script type=\"text/javascript\" src=\"" + ResolveUrl(this.BasePath + "tiny_mce.js") + "\"></script>"); } else { this.Page.ClientScript.RegisterClientScriptBlock( this.GetType(), "tinymcemain", "<script type=\"text/javascript\" src=\"" + ResolveUrl(this.BasePath + "tinymce.min.js") + "\"></script>"); } StringBuilder setupScript = new StringBuilder(); setupScript.Append("function mojoTinyMCEOnChangeHandler(inst) {"); //setupScript.Append("hookupGoodbyePrompt(\"" + Page.Server.HtmlEncode(Resource.UnSavedChangesPrompt) + "\"); "); setupScript.Append("hookupGoodbyePrompt(\"" + Resource.UnSavedChangesPrompt.HtmlEscapeQuotes().RemoveLineBreaks() + "\"); "); setupScript.Append("} "); Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "tinymceExitPrompt", "\n<script type=\"text/javascript\">\n" + setupScript.ToString() + "\n</script>"); setupScript = new StringBuilder(); setupScript.Append("\n<script type=\"text/javascript\">"); //this older approach did not work inside tabs // so we switched to use the editor constructor //setupScript.Append("tinyMCE.init({"); //setupScript.Append("mode :\"specific_textareas\" "); //setupScript.Append(", editor_selector : \"mceEditor\" "); //if (BasePath.Contains("tiny_mce")) //{ setupScript.Append(" var ed" + this.ClientID + " = new tinymce.Editor('" + this.ClientID + "', { "); //} //else //{ // setupScript.Append("tinyMCE.init({"); // setupScript.Append("selector: 'textarea#" + this.ClientID + "',"); // setupScript.Append("theme: 'modern',"); //} setupScript.Append("accessibility_focus : true "); //waiting for the 3.5 branch of TinyMCE to comeout of beta // it has more support for html 5 setupScript.Append(", schema :'" + WebConfigSettings.TinyMceSchema + "' "); //http://www.tinymce.com/tryit/html5_formats.php // setupScript.Append(",style_formats :[{title : 'section', block : 'section', wrapper: true, merge_siblings: false},"); // setupScript.Append("{title : 'article', block : 'article', wrapper: true, merge_siblings: false},"); // setupScript.Append("{title : 'aside', block : 'aside', wrapper: true},"); // setupScript.Append("{title : 'figure', block : 'figure', wrapper: true}]"); //if (!AccessibilityFocus) // true is default //{ // setupScript.Append(", accessibility_focus : false "); //} if (!AccessibilityWarnings) { setupScript.Append(", accessibility_warnings : false "); } setupScript.Append(", browsers : \"" + this.Browsers + "\""); setupScript.Append(",forced_root_block:'" + forcedRootBlock + "'"); if (!CustomShortcuts) { setupScript.Append(", custom_shortcuts : false "); } if (!convertUrls) { setupScript.Append(", convert_urls : false "); } // added 2009-12-15 previously TinyMCE was encoding German chars and this made it not find matches in search index setupScript.Append(", entity_encoding : 'raw' "); //setupScript.Append(",encoding :'xml'"); setupScript.Append(", dialog_type : \"" + this.DialogType + "\""); CultureInfo culture; if (WebConfigSettings.UseCultureOverride) { culture = SiteUtils.GetDefaultUICulture(); } else { culture = CultureInfo.CurrentUICulture; } setupScript.Append(",language:'" + culture.TwoLetterISOLanguageName + "'"); if (culture.TextInfo.IsRightToLeft) { textDirection = "rtl"; } if (extendedValidElements.Length > 0) { setupScript.Append(",extended_valid_elements:\"" + extendedValidElements + "\""); } //extended_valid_elements setupScript.Append(",directionality:\"" + this.TextDirection + "\""); setupScript.Append(",editor_deselector:\"" + this.DeSelectorCSSClass + "\""); if (spellCheckerUrl.Length > 0) { setupScript.Append(", spellchecker_rpc_url:\"" + spellCheckerUrl + "\""); } else { if (EnableGeckoSpellCheck) { setupScript.Append(",gecko_spellcheck : true "); } } if ((plugins.Contains("spellchecker")) && (SpellCheckerLanguages.Length > 0)) { setupScript.Append(",spellchecker_languages:\"" + SpellCheckerLanguages + "\""); } //setupScript.Append(", language : \"" + this.Language + "\""); setupScript.Append(",body_class:'" + editorBodyCssClass + "'"); if (!EnableObjectResizing) { setupScript.Append(", object_resizing : false "); } if (Plugins.Length > 0) { setupScript.Append(", plugins : \"" + this.Plugins + "\""); if (Plugins.Contains("preview")) { setupScript.Append(",plugin_preview_width:'850'"); setupScript.Append(",plugin_preview_height:'900'"); } //TODO: populate from style templates for a element //http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink //This option should contain a semicolon separated list of class titles and class names separated by = //advlink_styles : “Code=code;Excel=excel;Flash=flash;Sound=sound;Office=office;PDF=pdf;Image=image;PowerPoint=powerpoint;Word=word;Video=video” //advlink_styles //setupScript.Append(",media_strict:false"); } //setupScript.Append(",apply_source_formatting:true"); //if (UseStrictLoadingMode) //{ // setupScript.Append(", strict_loading_mode : true "); //} setupScript.Append(", theme : \"" + this.Theme + "\""); if (!EnableUndoRedo) { setupScript.Append(", custom_undo_redo : false "); } if (EnableUndoRedo) { setupScript.Append(", custom_undo_redo_levels : " + this.UnDoLevels.ToString()); } if (Theme == "advanced") { setupScript.Append(", layout_manager : \"" + this.AdvancedLayoutManager + "\""); setupScript.Append(", theme_advanced_blockformats : \"" + this.AdvancedBlockFormats + "\""); if (AdvancedStyles.Length > 0) { setupScript.Append(", theme_advanced_styles : \"" + this.AdvancedStyles + "\""); } setupScript.Append(", theme_advanced_source_editor_width : \"" + this.AdvancedSourceEditorWidth + "\""); setupScript.Append(", theme_advanced_source_editor_height : \"" + this.AdvancedSourceEditorHeight + "\""); if (!AdvancedSourceEditorWrap) { setupScript.Append(", theme_advanced_source_editor_wrap : false "); } if (AdvancedLayoutManager == "SimpleLayout") { setupScript.Append(", theme_advanced_toolbar_location : \"" + this.AdvancedToolbarLocation + "\""); setupScript.Append(", theme_advanced_toolbar_align : \"" + this.AdvancedToolbarAlign + "\""); setupScript.Append(", theme_advanced_statusbar_location : \"" + this.AdvancedStatusBarLocation + "\""); setupScript.Append(", theme_advanced_buttons1 : \"" + this.AdvancedRow1Buttons + "\""); setupScript.Append(", theme_advanced_buttons2 : \"" + this.AdvancedRow2Buttons + "\""); setupScript.Append(", theme_advanced_buttons3 : \"" + this.AdvancedRow3Buttons + "\""); //setupScript.Append(", theme_advanced_buttons1_add : \"pastetext,pasteword,selectall\""); setupScript.Append(",theme_advanced_resizing : true "); } //advanced theme has 2 skins default and o2k7 // o2k7 also supports skin_variant with default, silver and black as options // so basically we have // default // o2k7default // o2k7silver // o2k7black switch (skin) { case "o2k7default": setupScript.Append(",skin :'o2k7'"); break; case "o2k7silver": setupScript.Append(",skin :'o2k7'"); setupScript.Append(",skin_variant :'silver'"); break; case "o2k7black": setupScript.Append(",skin :'o2k7'"); setupScript.Append(",skin_variant :'black'"); break; case "default": default: //do nothing break; } if (templatesUrl.Length > 0) { setupScript.Append(",template_external_list_url: \"" + this.templatesUrl + "\""); } if (!Cleanup) { setupScript.Append(", cleanup : false "); } if (CleanupOnStart) { setupScript.Append(", cleanup_on_startup : true "); } //setupScript.Append(",convert_newlines_to_brs : true "); if (!InlineStyles) { setupScript.Append(", inline_styles : false "); } if (EditorAreaCSS.Length > 0) { setupScript.Append(", content_css : \"" + this.EditorAreaCSS + "\""); } if (emotionsBaseUrl.Length > 0) { setupScript.Append(",emotions_images_url : '" + emotionsBaseUrl + "'"); } if (AutoFocus) { setupScript.Append(", auto_focus : \"" + this.ClientID + "\" "); } if ((enableFileBrowser) && (fileManagerUrl.Length > 0)) { setupScript.Append(",file_browser_callback : 'myFileBrowser' "); } setupScript.Append(",onchange_callback : 'mojoTinyMCEOnChangeHandler' "); if (forcePasteAsPlainText) { //setupScript.Append(",oninit:'setPlainText'"); setupScript.Append(",paste_text_sticky:true"); setupScript.Append(",setup : function(ed) {"); setupScript.Append("ed.onInit.add(function(ed) {"); setupScript.Append("ed.pasteAsPlainText = true;"); setupScript.Append("});}"); } } setupScript.Append("}); "); if (plugins.Contains("fullpage")) { StringBuilder supScript = new StringBuilder(); supScript.Append("\n<script type=\"text/javascript\">"); supScript.Append("var editorContentFilter = {"); supScript.Append("setContent: function(originalContent) {"); supScript.Append(" var headMatch = originalContent.match(/<head>(.|\\n|\\r)*?<\\/head>/i);"); supScript.Append("if (headMatch) {"); supScript.Append("var headText = headMatch[0];"); supScript.Append("var stylesMatch = headText.match(/<style(.|\\n|\\r)*?>(.|\\n|\\r)*?<\\/style>/ig);"); supScript.Append("if (stylesMatch) {"); supScript.Append("var styleText = \"\";"); supScript.Append("for (var i = 0; i < stylesMatch.length; i++) {"); supScript.Append("styleText += stylesMatch[i];"); supScript.Append("}"); supScript.Append("originalContent = originalContent.replace(/<body((.|\\n|\\r)*?)>/gi, \"<body$1><!--style begin-->\" + styleText + \"<!--style end-->\");"); supScript.Append("}"); supScript.Append("}"); supScript.Append("return originalContent;"); supScript.Append("},"); supScript.Append("getContent: function(originalContent) {"); supScript.Append(" return originalContent.replace(/<!--style begin-->(.|\\n|\\r)*?<!--style end-->/g, '');"); supScript.Append("}"); supScript.Append("};"); supScript.Append("</script>"); this.Page.ClientScript.RegisterClientScriptBlock( typeof(Page), "tmcfpfix", supScript.ToString()); setupScript.Append("ed" + this.ClientID + ".onBeforeSetContent.add(function(ed, o) {"); setupScript.Append("o.content = editorContentFilter.setContent(o.content);"); setupScript.Append(" });"); setupScript.Append("ed" + this.ClientID + ".onGetContent.add(function(ed, o) {"); setupScript.Append("o.content = editorContentFilter.getContent(o.content);"); setupScript.Append(" });"); } setupScript.Append("ed" + this.ClientID + ".render(); "); //if (forcePasteAsPlainText) //{ // setupScript.Append("ed" + this.ClientID + ".onPaste.add( function(ed, e, o){ "); // setupScript.Append("ed.execCommand('mcePasteText', true); "); // setupScript.Append("ed.execCommand('mceAddUndoLevel');"); // setupScript.Append("return tinymce.dom.Event.cancel(e); "); // setupScript.Append("});"); //} setupScript.Append("</script>"); this.Page.ClientScript.RegisterStartupScript( this.GetType(), this.UniqueID, setupScript.ToString()); if ((enableFileBrowser) && (fileManagerUrl.Length > 0)) { SetupFileBrowserScript(); } //string submitScript = " tinyMCE.triggerSave(false,true); "; ////submitScript = " alert(tinyMCE.getContent('" + this.ClientID + "')); return false; "; //this.Page.ClientScript.RegisterOnSubmitStatement( // this.GetType(), "tmsubmit", submitScript); }