KnowledgeBase.KB.Tell C# (CSharp) Method

Tell() public method

public Tell ( Name property, Name value, Name perspective ) : void
property Name
value Name
perspective Name
return void
        public void Tell(Name property, Name value, Name perspective)
        {
            if (property.IsPrimitive)
                throw new ArgumentException("The given property name cannot be a primitive value.",nameof(property));

            if (!property.IsConstant)
                throw new ArgumentException("The given property name is not constant. Only constant names can be stored",nameof(property));

            var ToMList = AssertPerspective(perspective, nameof(perspective));
            property = RemovePropertyPerspective(property, ToMList);

            //ToM property shift
            property = ExtractPropertyFromToM(property, ToMList, nameof(property));

            if (m_dynamicProperties.Unify(property).Any())
                throw new ArgumentException("The given name will be objuscated by a dynamic property", nameof(property));

            var fact = property.ApplyToTerms(p => SimplifyProperty(p, ToMList));

            KnowledgeEntry entry;
            if (!m_knowledgeStorage.TryGetValue(fact, out entry))
            {
                entry = new KnowledgeEntry();
                m_knowledgeStorage[fact] = entry;
            }

            var mind_key = ToMList2Key(ToMList);
            entry.TellValueFor(mind_key,value);
            if (entry.IsEmpty())
                m_knowledgeStorage.Remove(fact);
        }

Same methods

KB::Tell ( Name property, Name value ) : void

Usage Example

Example #1
0
 public void Test_DynamicProperty_Regist_Fail_ConstantProperties()
 {
     var kb = new KB((Name)"Me");
     Assert.Throws<ArgumentException>(() =>
     {
         kb.Tell((Name)"Count(John)", Name.BuildName(3));
         kb.RegistDynamicProperty((Name)"Count", DummyCount);
     });
 }
All Usage Examples Of KnowledgeBase.KB::Tell