/// <summary> /// convienance method for creating a Non-Shadow fact. /// </summary> /// <param name="data">The data.</param> /// <param name="dclass">The dclass.</param> /// <param name="id">The id.</param> /// <returns></returns> protected internal virtual IFact createNSFact(Object data, Defclass dclass, long id) { Deftemplate dft = (Deftemplate)CurrentFocus.getTemplate(dclass); NSFact fact = new NSFact(dft, dclass, data, dft.AllSlots, id); return(fact); }
/// <summary> /// The implementation will look in the current module in focus. If it isn't /// found, it will search the other modules. The last module it checks should /// be the main module. /// </summary> /// <param name="data">The data.</param> /// <param name="dclass">The dclass.</param> /// <param name="template">The template.</param> /// <param name="id">The id.</param> /// <returns></returns> protected internal virtual IFact createFact(Object data, Defclass dclass, String template, long id) { IFact ft = null; ITemplate dft = null; if (template == null) { dft = CurrentFocus.getTemplate(dclass.ClassObject.FullName); } else { dft = CurrentFocus.getTemplate(template); } // if the deftemplate is null, check the other modules if (dft == null) { // Get the entry set from the agenda and iterate IEnumerator itr = modules.Values.GetEnumerator(); while (itr.MoveNext()) { IModule mod = (IModule)itr.Current; if (mod.containsTemplate(dclass)) { dft = mod.getTemplate(dclass); } } // we've searched every module, so now check main if (dft == null && main.containsTemplate(dclass)) { dft = main.getTemplate(dclass); } else { // throw an exception throw new AssertException("Could not find the template"); } } ft = dft.createFact(data, dclass, id); return(ft); }