static public Unifiable SetSettingForType(string subject, SubQuery query, ISettingsDictionary dict, string name, string gName, object value, string setReturn, XmlNode templateNode) { string _sreturn = setReturn; setReturn = StaticXMLUtils.GetAttribValue <string>(templateNode, "set-return", () => _sreturn, query.ReduceStarAttribute <string>); Request request = query.Request; AltBot TargetBot = request.TargetBot; // try to use a global blackboard predicate User gUser = TargetBot.ExemplarUser; string realName; Unifiable resultGet = SettingsDictionaryReal.grabSettingDefaultDict(dict, name, out realName); bool shouldSet = ShouldSet(templateNode, dict, realName, value, resultGet, query); User user = query.CurrentUser; ITripleStore userbotLuceneIndexer = (ITripleStore)user.mbot.TripleStore; string userName = user.UserID; if (!shouldSet) { writeToLog("!shouldSet ERROR {0} name={1} value={2} old={3}", dict, realName, value, resultGet); bool shouldSet2 = ShouldSet(templateNode, dict, realName, value, resultGet, query); return(ReturnSetSetting(dict, name, setReturn)); } if (IsIncomplete(value)) { if (UseLuceneForSet && userbotLuceneIndexer != null) { userbotLuceneIndexer.retractAllTriple(userName, name); } SettingsDictionaryReal.removeSettingWithUndoCommit(query, dict, name); if (!IsNullOrEmpty(gName)) { SettingsDictionaryReal.removeSettingWithUndoCommit(query, gUser, gName); } } else { if (UseLuceneForSet && userbotLuceneIndexer != null) { userbotLuceneIndexer.updateTriple(userName, name, value); } if (!String.IsNullOrEmpty(gName)) { SettingsDictionaryReal.addSettingWithUndoCommit(query, gUser.Predicates, gUser.addSetting, gName, value); } query.SetDictValue++; SettingsDictionaryReal.addSettingWithUndoCommit(query, dict, dict.addSetting, name, value); } var retVal = ReturnSetSetting(dict, name, setReturn); if (!IsIncomplete(retVal) || !IsNullOrEmpty(retVal)) { string comment = null; //if (query.LastTagHandler!=null) comment = query.LastTagHandler.Succeed(" setting " + name); return(retVal);// +comment; } return(retVal); }
/// <summary> /// Removes the named setting from this class /// </summary> /// <param name="name">The name of the setting to remove</param> public bool removeSetting(string name) { return(SettingsDictionaryReal.removeSettingWithUndoCommit(this, TargetSettings, name)); }