public bool ExistsTreeNode(string path) { if (path.IsNullOrEmpty()) { return(true); } string[] splitPaths = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (splitPaths.Length == 0) { return(true); } PlugInTreeNode current = this; foreach (string p in splitPaths) { if (!current.Children.TryGetValue(p, out current)) { return(false); } } return(true); }
public PlugInTreeNode CreatePath(string path) { if (path.IsNullOrEmpty()) { return(this); } string[] splitPaths = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (splitPaths.Length == 0) { return(this); } PlugInTreeNode current = this; foreach (string p in splitPaths) { if (!current.Children.ContainsKey(p)) { current.Children[p] = new PlugInTreeNode(); } current = current.Children[p]; } return(current); }
public PlugInTreeNode GetTreeNode(string path, bool throwOnNotFound) { if (path.IsNullOrEmpty()) { return(this); } string[] splitPaths = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (splitPaths.Length == 0) { return(this); } PlugInTreeNode current = this; foreach (string p in splitPaths) { if (current == null || !current.Children.TryGetValue(p, out current)) { if (throwOnNotFound) { log.ErrorFormat("指定扩展点路径不存在. Not found path is {0} , full path is {1}", p, path); return(null); //throw new Exception("指定扩展点路径不存在. Not found path is " + p + " , full path is " + path); } else { return(null); } } } return(current); }
public static object BuildItem(string path, object caller) { int pos = path.LastIndexOf('/'); string parent = path.Substring(0, pos); string child = path.Substring(pos + 1); PlugInTreeNode node = RootNode.GetTreeNode(parent); return(node.BuildChildItem(child, caller, new ArrayList(BuildItems <object>(path, caller, false)))); }
public static List <T> BuildItems <T>(string path, object caller, bool throwOnNotFound) { PlugInTreeNode node = RootNode.GetTreeNode(path, throwOnNotFound); if (node == null) { return(new List <T>()); } else { return(node.BuildChildItems <T>(caller)); } }
private static void ParsePlugInFiles() { PlugIn plugIn; foreach (string file in plugInFiles) { try { plugIn = PlugIn.Load(file); } catch (Exception ex) { log.ErrorFormat("Error loading PlugIn {0} :\n{1}", file, ex.Message); plugIn = new PlugIn(); plugIn.PlugInFile = file; plugIn.CustomErrorMsg = ex.Message; } if (plugIn.CustomErrorMsg.IsNotNullOrEmpty()) { plugInsList.Add(plugIn); continue; } plugIn.Enabled = true; if (disabledList != null && disabledList.Count > 0) { foreach (string dir in disabledList) { if (plugIn.PlugInDir.IndexOf(dir) >= 0) { plugIn.Enabled = false; break; } } } if (plugIn.Enabled) { plugInsList.Add(plugIn); foreach (ExtensionPath path in plugIn.Paths.Values) { PlugInTreeNode treePath = RootNode.CreatePath(path.Name); treePath.AddCodons(path.Codons); } foreach (Runtime runtime in plugIn.Runtimes) { foreach (LazyDoozer doozer in runtime.DefinedDoozers) { if (Doozers.ContainsKey(doozer.Name)) { throw new Exception("Duplicate doozer: " + doozer.Name); } Doozers.Add(doozer.Name, doozer); } } } } }