Ejemplo n.º 1
0
        /// <summary>
        /// Adds a bespoke setting to the Settings class (accessed via the grabSettings(string name)
        /// method.
        /// </summary>
        /// <param name="name">The name of the new setting</param>
        /// <param name="value">The value associated with this setting</param>
        public bool addSetting(string name, object value)
        {
            ISettingsDictionary dict = Request.TargetSettings;

            if (!UseLuceneForSet)
            {
                return(SettingsDictionaryReal.addSettingWithUndoCommit(this, dict, dict.addSetting, name, value));
            }
            else
            {
                string realName;
                bool   succeed;

                var prev = NamedValuesFromSettings.UseLuceneForGet;
                NamedValuesFromSettings.UseLuceneForGet = true;
                try
                {
                    NamedValuesFromSettings.SetSettingForType(dict.NameSpace, this, dict, name, null, value, null, null);
                }
                finally
                {
                    NamedValuesFromSettings.UseLuceneForGet = prev;
                }
                return(true);
            }
        }
Ejemplo n.º 2
0
        public DataUnifiable grabSetting(string name)
        {
            string realName;
            ISettingsDictionary dict = Request.TargetSettings;
            bool      succeed;
            Unifiable v;

            if (!UseLuceneForGet)
            {
                v = SettingsDictionaryReal.grabSettingDefaultDict(dict, name, out realName);
            }
            else
            {
                v = NamedValuesFromSettings.GetSettingForType(dict.NameSpace, this, dict, name, out realName, name, null,
                                                              out succeed, null);
            }
            return(v);
        }
Ejemplo n.º 3
0
        protected override Unifiable ProcessChangeU()
        {
            Unifiable defaultVal = GetAttribValue("default,defaultValue", null);

            if (CheckNode("set"))
            {
                var                 templateNodeInnerText = Recurse();
                Unifiable           name  = GetAttribValue("name,var", null);
                Unifiable           value = GetAttribValue("value", null);
                string              gName = GetAttribValue("global_name", null);
                ISettingsDictionary dict;
                string              dictName = GetNameOfDict(query, "set", templateNode, out dict);
                Succeed();
                if (name == null)
                {
                    //recursive form like <set>name value Unifiable</set>
                    name = templateNodeInnerText.First;
                    var strV = templateNodeInnerText.Rest;
                    if (!IsNull(strV))
                    {
                        if (IsNull(value))
                        {
                            value = strV;
                        }
                        else
                        {
                            writeToLogWarn("ERROR extra stuff in ", strV);
                        }
                    }
                }
                else
                {
                    if (value == null)
                    {
                        var strV = templateNodeInnerText;
                        if (IsNull(strV))
                        {
                            writeToLogWarn("ERROR null stuff in SET ", strV);
                        }
                        value = strV;
                    }
                }
                string setReturn = GetAttribValue <string>(templateNode, "set-return",
                                                           () => ((string)Proc.GetRelationMetaProps().GetMeta(name, "set-return")),
                                                           ReduceStarAttribute <string>);
                if (value == null)
                {
                    value = templateNodeInnerText;
                }
                if (IsNull(value))
                {
                    value = defaultVal;
                }
                if (IsNull(value))
                {
                    if (QueryHasFailed)
                    {
                        return(FAIL);
                    }
                }
                var retVal = NamedValuesFromSettings.SetSettingForType(dictName, query, dict, name, gName, value, setReturn, templateNode);
                if (IsNull(retVal))
                {
                    writeToLogWarn("ERROR null stuff in SET ", retVal);
                }
                else if (IsIncomplete(retVal))
                {
                    writeToLogWarn("ERROR null stuff in SET ", retVal);
                }
                return(retVal);
            }
            return(defaultVal);
        }