Пример #1
0
 /// <summary>
 /// Removes an attribute value from the key.
 /// </summary>
 /// <param name="tariffAttributeValue">Attribute value to be removed.</param>
 /// <exception cref="InvalidAttributeValueException">Thrown when the key does not hold the value to be removed.</exception>
 public void Remove(TariffAttributeValue tariffAttributeValue)
 {
     if (!TariffAttributeValues.Contains(tariffAttributeValue))
     {
         throw new InvalidAttributeValueException("The key does not hold the value to be removed.");
     }
     TariffAttributeValues.Remove(tariffAttributeValue);
 }
Пример #2
0
        /// <summary>
        /// Adds an attribute value to the key.
        /// </summary>
        /// <param name="tariffAttributeValue">Attribute value to be added to the key.</param>
        /// <exception cref="InvalidAttributeValueException">Thrown when the key already holds a valid value for the attribute the added value is associated to.</exception>
        public void Add(TariffAttributeValue tariffAttributeValue)
        {
            if (ContainsAttribute(tariffAttributeValue.Attribute))
            {
                throw new InvalidAttributeValueException("The key already holds a value for this value's associated attribute.");
            }

            TariffAttributeValues.Add(tariffAttributeValue);
        }
Пример #3
0
        /// <summary>
        /// Adds a TariffAttributeValue to the attribute.
        /// </summary>
        /// <param name="attributeValue">TariffAttributeValue to be added.</param>
        /// /// <exception cref="InvalidAttributeValueException">Thrown when the attribute of the attribute value differs from this attribute.</exception>
        public void Add(TariffAttributeValue attributeValue)
        {
            if (attributeValue.Attribute != this)
            {
                throw new InvalidAttributeValueException("The value's attribute does not match the attribute it is to be added to.");
            }

            Values.Add(attributeValue);
        }
Пример #4
0
        /// <summary>
        /// Indexer to retrieve a valid value of the attribute.
        /// </summary>
        /// <param name="val">Description of the attribute value as plain text.</param>
        /// <returns>An instance of the TariffAttributeValue struct representing a valid value for this attribute.</returns>
        /// <exception cref="InvalidAttributeValueException">Thrown when a value that is not legal for this attribute is tried to be accessed.</exception>
        public TariffAttributeValue this[string val]
        {
            get
            {
                TariffAttributeValue attributeValue = new TariffAttributeValue(this, val);

                if (!Values.Contains(attributeValue))
                {
                    throw new InvalidAttributeValueException();
                }

                return(attributeValue);
            }
        }
Пример #5
0
        /// <summary>
        /// Remoces a TaiffAttributeValue from the attribute.
        /// </summary>
        /// <param name="attributeValue">TariffAttributeValue to be removed.</param>
        /// <exception cref="InvalidAttributeValueException">Thrown when the attribute of the attribute value differs from this attribute.</exception>
        /// <exception cref="InvalidAttributeValueException">Thrown when the Values set does not contain the value to be removed.</exception>
        public void Remove(TariffAttributeValue attributeValue)
        {
            if (attributeValue.Attribute != this)
            {
                throw new InvalidAttributeValueException("The value's attribute does not match the attribute it is to be added to.");
            }

            if (!Values.Contains(attributeValue))
            {
                throw new InvalidAttributeValueException();
            }

            Values.Remove(attributeValue);
        }
Пример #6
0
 /// <summary>
 /// Checks whether the given attribute value is part of the key.
 /// </summary>
 /// <param name="tariffAttributeValue">Attribute value to be checked.</param>
 /// <returns>True, if the key contains the attribute value, false otherwise.</returns>
 public bool Contains(TariffAttributeValue tariffAttributeValue)
 {
     return(TariffAttributeValues.Contains(tariffAttributeValue));
 }