Example #1
0
        /// <summary>
        /// Sets value for key. If item exists for alt key, replace it.
        /// </summary>
        public static void SetOrChange(this PDictionary dict, string key, string altKey, string value)
        {
            var keyItem = dict.Get <PString> (key);
            var altItem = dict.Get <PString> (altKey);

            if (keyItem == null)
            {
                if (altItem != null)
                {
                    dict.ChangeKey(altItem, key);
                    altItem.Value = value;
                }
                else
                {
                    dict[key] = new PString(value);
                }
            }
            else
            {
                if (altItem != null)
                {
                    dict.Remove(altKey);
                }
                keyItem.Value = value;
            }
        }