Esempio n. 1
0
        public string GenFormatFactoid(string subject, string relation, object value, XmlNode templateNode)
        {
            string subj       = Entify(subject);
            var    dictionary = TheBot.GetDictionary(subj) as SettingsDictionary;

            bool      noValue = Unifiable.IsNullOrEmpty(value);
            Unifiable formatter;
            {
                if (noValue)
                {
                    // query mode
                    formatter = GetDictValue(dictionary, relation, "format-query");
                }
                else
                {
                    // assert mode
                    formatter = GetDictValue(dictionary, relation, "format-assert");
                }
            }

            var formatterUpper = Unifiable.ToUpper(formatter);

            if (Unifiable.IsNullOrEmpty(formatter) || Unifiable.IsTrueOrYes(formatterUpper) || formatter == "default")
            {
                formatter = " {0} {1} is {2} ";
            }

            if (Unifiable.IsFalseOrNo(formatterUpper))
            {
                return("false");
            }

            return(ExpandFormat(subj, relation, value, noValue, dictionary, formatter, templateNode));
        }