コード例 #1
0
        protected CompiledKnowledgeBase(SerializationInfo info, StreamingContext context)
        {
            this._synonyms            = (Hashtable)info.GetValue("s", typeof(Hashtable));
            this._replacements        = (ArrayList)info.GetValue("r", typeof(ArrayList));
            this._inputs              = (Hashtable)info.GetValue("i", typeof(Hashtable));
            this._outputs             = (Hashtable)info.GetValue("o", typeof(Hashtable));
            this._knowledgeBaseItem   = (KnowledgeBaseItem)info.GetValue("k", typeof(KnowledgeBaseItem));
            this._knowledgeBaseInfo   = (KnowledgeBaseInfo)info.GetValue("kbi", typeof(KnowledgeBaseInfo));
            this._build               = info.GetInt32("b");
            this._random              = new Random();
            this._recentOutputsByRule = new Hashtable();

            //use a try/catch block around any new vales
            try
            {
                this._inputReplacements = (ArrayList)info.GetValue("ir", typeof(ArrayList));
            }
            catch
            {
                this._inputReplacements = new ArrayList();
            }

            this.InitializeCsToolbox();
            try
            {
                this._csToolbox.CodeModules = (ArrayList)info.GetValue("cm", typeof(ArrayList));
            }
            catch
            {
                this._csToolbox.CodeModules = new ArrayList();
            }
        }
コード例 #2
0
        public void ReloadKnowledgeBase(KnowledgeBase kb, KnowledgeBaseItem knowledgeBaseItem)
        {
            var ckb    = this.LoadKnowledgeBase(kb, knowledgeBaseItem);
            var stPath = knowledgeBaseItem.Fullpath + knowledgeBaseItem.Filename;

            this._compiledKnowledgeBases[stPath] = ckb;
        }
コード例 #3
0
        public CompiledKnowledgeBase AddKnowledgeBase(KnowledgeBase kb, KnowledgeBaseItem knowledgeBaseItem)
        {
            var ckb    = this.LoadKnowledgeBase(kb, knowledgeBaseItem);
            var stPath = knowledgeBaseItem.Fullpath + knowledgeBaseItem.Filename;

            if (ckb != null)
            {
                this._compiledKnowledgeBases[stPath] = ckb;
            }
            return(ckb);
        }
コード例 #4
0
        [NonSerialized] public string Name; //This is just used for comparison when reloading

        public CompiledKnowledgeBase()
        {
            this.KbList             = new List <KnowledgeBase>();
            this._synonyms          = new Hashtable();
            this._replacements      = new ArrayList();
            this._inputReplacements = new ArrayList();
            this._inputs            = new Hashtable();
            this._outputs           = new Hashtable();
            this._knowledgeBaseItem = new KnowledgeBaseItem();
            this._knowledgeBaseInfo = new KnowledgeBaseInfo();
            this._build             = -1;
            this.Name    = "";
            this._random = new Random();
            this._recentOutputsByRule = new Hashtable();
            this.InitializeCsToolbox();
        }
コード例 #5
0
        public CompiledKnowledgeBase LoadKnowledgeBase(KnowledgeBase kb, KnowledgeBaseItem knowledgeBaseItem)
        {
            var ckb = new CompiledKnowledgeBase
            {
                Build = kb.Build,
                Name  = knowledgeBaseItem.Fullpath + knowledgeBaseItem.Filename
            };

            ckb.KbList.Add(kb);
            ckb.OnRuleCompiled      += this.compiledKnowledgeBase_OnRuleCompiled;
            ckb.OnRuleCompileFailed += this.compiledKnowledgeBase_OnRuleCompileFailed;
            ckb.OnCompileError      += ckb_OnCompileError;
            ckb.OnCompileWarning    += ckb_OnCompileWarning;
            ckb.LoadKnowledgeBase(kb, knowledgeBaseItem);
            return(ckb);
        }
コード例 #6
0
 public CompiledKnowledgeBase CompileKnowledgeBase(KnowledgeBase kb, KnowledgeBaseItem knowledgeBaseItem)
 {
     return(LoadKnowledgeBase(kb, knowledgeBaseItem));
 }