/// <summary> /// Search for VE plugin /// </summary> /// <param name="content"></param> /// <returns></returns> public pluginner.IVEPlugin GetFCVEplugin(string content) { //поиск плагина FC VE foreach (string CurDescription in VEPlugins) { string[] Parts = CurDescription.Split(";".ToCharArray()); if (System.Text.RegularExpressions.Regex.IsMatch(content, Parts[0])) { //оно! return(LoadFCVEPlugin(Parts[1])); } } return(new base_plugins.ve.PlainText()); //если ничего лучшего не найти, тогда дать что имеется }
/// <summary> /// Searches for the good FS plugin to work with filesystem of the file/directory <paramref name="url"/> /// </summary> /// <param name="url">The uniform resource locator for the requested file</param> /// <returns>The good filesystem plugin (IFSPlugin-based class) or an exception if no plugins found</returns> public pluginner.IFSPlugin GetFSplugin(string url) { string[] UrlParts = url.Split("://".ToCharArray()); foreach (string CurDescription in FSPlugins) { string[] Parts = CurDescription.Split(";".ToCharArray()); if (System.Text.RegularExpressions.Regex.IsMatch(UrlParts[0], Parts[0])) { //оно! if (Parts[1].StartsWith("(internal)")) { //плагин встроенный switch (Parts[1]) { case "(internal)LocalFS": return(new fcmd.base_plugins.fs.localFileSystem()); } } else { //плагин внешний string file = Parts[1]; Assembly assembly = Assembly.LoadFile(file); foreach (Type type in assembly.GetTypes()) { Type iface = type.GetInterface("pluginner.IFSPlugin"); if (iface != null) { pluginner.IFSPlugin plugin = (pluginner.IFSPlugin)Activator.CreateInstance(type); return(plugin); } } } } } throw new PluginNotFoundException("Не найден плагин ФС для протокола " + UrlParts[0]); }