public ExtensionPath(string name, PlugIn plugIn) { Name = name; PlugIn = plugIn; Codons = new List<Codon>(); }
public Codon(PlugIn plugIn, string name, Properties properties) { PlugIn = plugIn; Name = name; Properties = properties; }
private static Runtime Read(PlugIn plugIn, XmlReader reader) { if (reader.AttributeCount != 1) { throw new Exception(PlugInConst.RuntimeImport + " node requires only one attribute."); } Runtime runtime = new Runtime(reader.GetAttribute(0), plugIn.PlugInDir); if (!reader.IsEmptyElement) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: string nodeName = reader.LocalName; Properties properties = Properties.ReadFromAttributes(reader); switch (nodeName) { case PlugInConst.RuntimeImportDoozer: if (reader.HasAttributes == false) { throw new Exception("Doozer node must be have attributes!"); } runtime.DefinedDoozers.Add(new LazyDoozer(plugIn, properties)); break; default: throw new Exception("Unknown node in Import section:" + nodeName); } break; case XmlNodeType.EndElement: if (reader.LocalName == PlugInConst.RuntimeImport) { runtime.DefinedDoozers = (runtime.DefinedDoozers as List <LazyDoozer>).AsReadOnly(); return(runtime); } break; } } } runtime.DefinedDoozers = (runtime.DefinedDoozers as List <LazyDoozer>).AsReadOnly(); return(runtime); }
public void ReadManifest(XmlReader reader, PlugIn plugIn) { if (reader.AttributeCount != 0) { throw new Exception(PlugInConst.Manifest + " node cannot have attributes."); } if (reader.IsEmptyElement) { throw new Exception(PlugInConst.Manifest + " node cannot be empty."); } while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: string nodeName = reader.LocalName; Properties properties = Properties.ReadFromAttributes(reader); switch (nodeName) { case PlugInConst.ManifestIdentity: AddIdentity(properties["name"], properties["version"], plugIn.PlugInDir); break; case PlugInConst.ManifestDependency: Dependencies.Add(PlugInReference.Create(properties, plugIn.PlugInDir)); break; case PlugInConst.ManifestConflict: Conflicts.Add(PlugInReference.Create(properties, plugIn.PlugInDir)); break; default: throw new Exception("Unknown node in " + PlugInConst.Manifest + " section:" + nodeName + " plugIn:" + plugIn.PlugInFile); } break; case XmlNodeType.EndElement: if (reader.LocalName == PlugInConst.Manifest) { return; } break; default: break; } } }
public void ReadManifest(XmlReader reader, PlugIn plugIn) { if (reader.AttributeCount != 0) { throw new Exception(PlugInConst.Manifest + " node cannot have attributes."); } if (reader.IsEmptyElement) { throw new Exception(PlugInConst.Manifest + " node cannot be empty."); } while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: string nodeName = reader.LocalName; Properties properties = Properties.ReadFromAttributes(reader); switch (nodeName) { case PlugInConst.ManifestIdentity: AddIdentity(properties["name"], properties["version"], plugIn.PlugInDir); break; case PlugInConst.ManifestDependency: Dependencies.Add(PlugInReference.Create(properties, plugIn.PlugInDir)); break; case PlugInConst.ManifestConflict: Conflicts.Add(PlugInReference.Create(properties, plugIn.PlugInDir)); break; default: throw new Exception("Unknown node in " + PlugInConst.Manifest + " section:" + nodeName + " plugIn:" + plugIn.PlugInFile); } break; case XmlNodeType.EndElement: if (reader.LocalName == PlugInConst.Manifest) return; break; default: break; } } }
static void Load(TextReader textReader, PlugIn plugIn) { using (XmlTextReader reader = new XmlTextReader(textReader)) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.LocalName) { case PlugInConst.RootElement: SetupPlugIn(reader, plugIn); break; default: throw new Exception("Unknow plug-in file."); } } } } }
public static PlugIn Load(string fileName) { try { using (TextReader textReader = File.OpenText(fileName)) { PlugIn plugIn = new PlugIn(); plugIn.PlugInFile = fileName; plugIn.PlugInDir = Path.GetDirectoryName(fileName); Load(textReader, plugIn); return(plugIn); } } catch (Exception ex) { log.Error("Error parse plug-in file.", ex); throw ex; } }
public static PlugIn Load(string fileName) { try { using (TextReader textReader = File.OpenText(fileName)) { PlugIn plugIn = new PlugIn(); plugIn.PlugInFile = fileName; plugIn.PlugInDir = Path.GetDirectoryName(fileName); Load(textReader, plugIn); return plugIn; } } catch (Exception ex) { log.Error("Error parse plug-in file.", ex); throw ex; } }
static void SetupPlugIn(XmlReader reader, PlugIn plugIn) { plugIn.Properties = Properties.ReadFromAttributes(reader); plugIn.Runtimes = new List<Runtime>(); plugIn.Paths = new Dictionary<string, ExtensionPath>(); plugIn.Manifest = new PlugInManifest(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.IsStartElement()) { switch (reader.LocalName) { case PlugInConst.Runtime: Runtime.ReadRuntime(reader, plugIn); break; case PlugInConst.Path: ExtensionPath.ReadPath(reader, plugIn); break; case PlugInConst.Manifest: plugIn.Manifest.ReadManifest(reader, plugIn); break; default: break; } } } }
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); } } } } }