コード例 #1
0
 public override void Add(string key, object value)
 {
     if (value.GetType().Equals(typeof(string)))
     {
         value = localizationService.ExtractExplicitResourceKey(key, value.ToString());
     }
     base.Add(key, value);
 }
コード例 #2
0
        /// <summary>
        /// Adds a new element to the dictionary with the specified key and value. If the key exists, the value will be overwritten.
        /// </summary>
        /// <param name="key">The key of the element to add.</param>
        /// <param name="value">The value of the element to add. The value can be null for reference types.</param>
        /// <param name="throwIfReservedKey"><c>true</c> to throw an exception if one of the keys being added is a reserved key name; otherwise, <c>false</c>.</param>
        public void Add(string key, object value, bool throwIfReservedKey)
        {
            if (this.reservedAttributeNameProvider.IsRegularAttribute(key))
            {
                if (value.GetType().Equals(typeof(string)))
                {
                    value = localizationService.ExtractExplicitResourceKey(key, value.ToString());
                }

                if (!this.ContainsKey(key))
                {
                    base.Add(key, value);
                }
                else
                {
                    base[key] = value;
                }
            }
            else if (throwIfReservedKey)
            {
                throw new ReservedKeyException(string.Format(Resources.Messages.AttributeKeyReserved, this.siteMapNodeKey, key, value));
            }
        }