SetValue() public static method

public static SetValue ( Mobile from, object o, string name, string value ) : string
from Mobile
o object
name string
value string
return string
コード例 #1
0
        public override void Execute(CommandEventArgs e, object obj)
        {
            string result = Properties.SetValue(e.Mobile, obj, m_Name, m_Value);

            if (result == "Property has been set.")
            {
                AddResponse(result);
            }
            else
            {
                LogFailure(result);
            }
        }
コード例 #2
0
        public override void Execute(CommandEventArgs e, object obj)
        {
            if (e.Length >= 2)
            {
                //3/8/2016, Adam Adam: This old implementation assumed a value would only have one part to the argument.
                //	But something like a time value can have two and maybe three. I.e., 3/6/2016 08:00:00
                // string prop = e.GetString(0);
                // string val = e.GetString(1);

                string prop = e.GetString(0);
                string val  = null;
                for (int ix = 1; ix < e.Length; ix++)
                {
                    val += e.GetString(ix) + " ";
                }
                val.TrimEnd();

                int p1 = val.IndexOf('%', 0);
                if (p1 >= 0)
                {
                    int p2 = val.IndexOf('%', p1 + 1);
                    if (p2 > 0)
                    {
                        //found a token, look it up.
                        string token       = val.Substring(p1 + 1, p2 - p1 - 1);
                        string token_value = Properties.GetOnlyValue(e.Mobile, obj, token);
                        if (token_value != null)
                        {
                            val = val.Replace("%" + token + "%", token_value);
                        }
                    }
                }

                string result = Properties.SetValue(e.Mobile, obj, prop, val);

                if (result == "Property has been set.")
                {
                    AddResponse(result);
                }
                else
                {
                    LogFailure(result);
                }
            }
            else
            {
                LogFailure("Format: Set <propertyName> <value>");
            }
        }