Ejemplo n.º 1
0
        public virtual string Get(string name)
        {
            // validation
            if (KB.Contains(name) == false)
            {
                throw new Exception(string.Format("The logical name '{0}' doesn't exist", name));
            }

            return(Convert.ToString(KB[name]));
        }
Ejemplo n.º 2
0
        public virtual void Remove(string name)
        {
            // validation
            if (AllowToUpdate == false)
            {
                throw new Exception("The Knowledge Base is locked");
            }
            if (KB.Contains(name) == false)
            {
                throw new Exception(string.Format("The logical name '{0}' doesn't exist", name));
            }

            // fire event
            if (OnBeforeClearKnowledgeBase(name) == false)
            {
                return;
            }

            // remove name from the KB
            KB.Remove(name);

            // fire event
            OnClearKnowledgeBase(name);
        }
Ejemplo n.º 3
0
        public virtual void Update(string name, string val)
        {
            // validation
            if (AllowToUpdate == false)
            {
                throw new Exception("The Knowledge Base is locked");
            }
            if (KB.Contains(name) == false)
            {
                throw new Exception(string.Format("The logical name '{0}' doesn't exist", name));
            }

            // fire event
            if (OnBeforeChangeKnowledgeBase(name, val) == false)
            {
                return;
            }

            // update value in the KB
            KB[name] = val;

            // fire event
            OnChangedKnowledgeBase(name, val);
        }
Ejemplo n.º 4
0
 public virtual bool Exists(string name)
 {
     return(KB.Contains(name));
 }
Ejemplo n.º 5
0
 public virtual string Mapping(string name)
 {
     return(KB.Contains(name) == true?Convert.ToString(KB[name]) : name);
 }