예제 #1
0
파일: Fact.cs 프로젝트: vkiktev/NxBRE
        /// <summary>
        /// Prepare the atom to be pattern matched by replacing in a fact:
        /// -  all the predicates that match function predicates in the passed atom with
        ///   the string representation of these function predicates,
        /// -  in fully mode, all the predicates that match individual predicates in the passed atom with
        ///   the string representation of these individual predicates.
        /// </summary>
        /// <remarks>
        /// This operation must be done *if and only if* the fact matches the atom.
        /// </remarks>
        /// <param name="fully">Forces resolution of non-string individual to String.</param>
        /// <param name="factToResolve">The fact that must be resolved.</param>
        /// <param name="atom">The atom with which the current fact matches.</param>
        /// <returns>A new fact with only String individuals.</returns>
        public static Fact Resolve(bool fully, Fact factToResolve, Atom atom)
        {
            IPredicate[] predicates = new IPredicate[factToResolve.Members.Length];

            for (int i = 0; i < factToResolve.Members.Length; i++)
            {
                if ((atom.Members[i] is Function) ||
                    ((fully) && (atom.Members[i] is Individual) && (!(factToResolve.Members[i].Value is System.String))))
                {
                    predicates[i] = new Individual(atom.Members[i].ToString());
                }
                else
                {
                    predicates[i] = factToResolve.Members[i];
                }
            }

            return((Fact)factToResolve.CloneWithNewMembers(predicates));
        }
예제 #2
0
파일: Fact.cs 프로젝트: Ghasan/NxBRE
        /// <summary>
        /// Prepare the atom to be pattern matched by replacing in a fact:
        /// -  all the predicates that match function predicates in the passed atom with 
        ///   the string representation of these function predicates,
        /// -  in fully mode, all the predicates that match individual predicates in the passed atom with 
        ///   the string representation of these individual predicates.
        /// </summary>
        /// <remarks>
        /// This operation must be done *if and only if* the fact matches the atom.
        /// </remarks>
        /// <param name="fully">Forces resolution of non-string individual to String.</param>
        /// <param name="factToResolve">The fact that must be resolved.</param>
        /// <param name="atom">The atom with which the current fact matches.</param>
        /// <returns>A new fact with only String individuals.</returns>
        public static Fact Resolve(bool fully, Fact factToResolve, Atom atom)
        {
            IPredicate[] predicates = new IPredicate[factToResolve.Members.Length];

            for(int i=0; i<factToResolve.Members.Length; i++) {
                if ((atom.Members[i] is Function)
                        || ((fully) && (atom.Members[i] is Individual) && (!(factToResolve.Members[i].Value is System.String)))) {
                    predicates[i] = new Individual(atom.Members[i].ToString());
                }
                else {
                    predicates[i] = factToResolve.Members[i];
                }
            }

            return (Fact)factToResolve.CloneWithNewMembers(predicates);
        }