public GenieAssistantConfigs(GenieConfig parent, XmlNode node) { this.ParentConfig = parent; foreach (XmlNode assistantNode in parent.Lamp.QueryNode(node, "./{0}:Assistant")) { GenieAssistantConfig assistantConfig = new GenieAssistantConfig(parent, assistantNode); this.Add(assistantConfig); } }
public GenieAssistantConfig(GenieConfig parentConfig, XmlNode node) { this.Name = Utils.Xml.GetAttrValue(node, "name"); this.AssemblyName = Utils.Xml.GetAttrValue(node, "assembly"); this.TypeName = Utils.Xml.GetAttrValue(node, "type"); this.ParentConfig = parentConfig; this.Params = new ParamsSimple(parentConfig.Lamp.QueryNode(node, "./{0}:Param"), parentConfig.Macro); }
public Genies(GenieLamp lamp, XmlNodeList nodes) { this.lamp = lamp; if (nodes == null || nodes.Count == 0) { throw new GlException("No genies to spell..."); } lamp.Logger.TraceLine("Initializing genies"); foreach (XmlNode genieNode in nodes) { GenieConfig genieConfig = new GenieConfig(lamp, genieNode); System.Type t = LoadPlugin(genieConfig.AssemblyName, genieConfig.TypeName); lamp.Logger.Trace(String.Format("{0}...", t.Name)); try { IGenie genie = Activator.CreateInstance(t) as IGenie; if (genie == null) { throw new GlException("Genie '{0}' doesn't implement {1}. Assembly: {2}. Type: {3}", genieConfig.Name, typeof(IGenie).Name, genieConfig.AssemblyName, genieConfig.TypeName); } genie.Init(genieConfig); lamp.Logger.TraceLine(String.Format("OK ({0})", genie.Name)); genies.Add(genie); // Load assistants genieConfig.Assistants.Clear(); foreach (GenieAssistantConfig assistantConfig in genieConfig.AssistantConfigs) { System.Type t2 = LoadPlugin(assistantConfig.AssemblyName, assistantConfig.TypeName); lamp.Logger.Trace(String.Format(" Assistant: {0}...", t2.Name)); IGenieAssistant genieAssistant = Activator.CreateInstance(t2) as IGenieAssistant; if (genieAssistant == null) { throw new GlException("Genie assistant '{0}' doesn't implement {1}. Assembly: {2}. Type: {3}", assistantConfig.Name, typeof(IGenieAssistant).Name, assistantConfig.AssemblyName, assistantConfig.TypeName); } genieAssistant.Init(assistantConfig, genie); genieConfig.Assistants.Add(genieAssistant); lamp.Logger.TraceLine(String.Format("OK ({0})", assistantConfig.Name)); } } catch (Exception) { lamp.Logger.TraceLine("FAILED"); throw; } } lamp.Logger.TraceLine("All genies initialized OK"); }
public GenieConfigParams(GenieConfig owner, XmlNodeList nodeList) : base(nodeList, owner.Macro) { this.owner = owner; }