KnowledgeBase.KB.AssertPerspective C# (CSharp) Method

AssertPerspective() private method

private AssertPerspective ( Name perspective, string argumentName ) : List
perspective Name The perspective to evaluate
argumentName string
return List
        private List<Name> AssertPerspective(Name perspective, string argumentName)
        {
            if(perspective == Name.NIL_SYMBOL)
                throw new ArgumentException("Perspectives cannot contain NIL symbol",argumentName);

            perspective = perspective.ApplyPerspective(Perspective);

            List<Name> ToMList = new List<Name>();
            if (perspective.IsUniversal)
            {
                ToMList.Add(Name.UNIVERSAL_SYMBOL);
                return ToMList;
            }

            ToMList.Add(Name.SELF_SYMBOL);
            if (perspective.IsPrimitive)
            {
                if(perspective != Name.SELF_SYMBOL)
                    ToMList.Add(perspective);

                return ToMList;
            }

            if (!perspective.IsConstant)
                throw new ArgumentException("The given Theory of the Mind perspective needs to be constant", argumentName);

            //Validate ToM definition and ToM level
            var eval = perspective;

            while (eval.IsComposed)
            {
                if (eval.NumberOfTerms > 2)
                    throw new ArgumentException($"Invalid perspective format {perspective}", argumentName);

                var f = eval.GetNTerm(0);

                AssetToMList(ToMList, f, argumentName);

                eval = eval.GetNTerm(1);
            }
            AssetToMList(ToMList, eval, argumentName);

            return ToMList;
        }

Same methods

KB::AssertPerspective ( Name perspective ) : Name