/// <summary>
        /// Check if the content of a value set is consistent with the number of time steps and the
        /// number of elements defined by the exchange item.
        /// </summary>
        /// <param name="exchangeItem">The exchange item specifying time and space</param>
        /// <param name="valueSet">The value set to be checked</param>
        public static void CheckValueSizes(ITimeSpaceExchangeItem exchangeItem, ITimeSpaceValueSet valueSet)
        {
            int timesCount = 1;

            if (exchangeItem.TimeSet != null)
            {
                if (exchangeItem.TimeSet.Times != null)
                {
                    timesCount = exchangeItem.TimeSet.Times.Count;
                }
                else
                {
                    timesCount = 0;
                }
            }

            if (ValueSet.GetTimesCount(valueSet) != timesCount)
            {
                throw new Exception("ExchangeItem \"" + exchangeItem.Caption +
                                    "\": Wrong #times in valueSet (" + ValueSet.GetTimesCount(valueSet) + "), expected #times (" + timesCount + ")");
            }

            int elementCount = 1;

            if (exchangeItem.ElementSet() != null)
            {
                elementCount = exchangeItem.ElementSet().ElementCount;
            }
            if (ValueSet.GetElementCount(valueSet) != elementCount)
            {
                throw new Exception("ExchangeItem \"" + exchangeItem.Caption +
                                    "\": Wrong #times in valueSet (" + ValueSet.GetElementCount(valueSet) + "), expected #times (" + elementCount + ")");
            }
        }
 /// <summary>
 /// Return the number of elements in the <see cref="ITimeSpaceValueSet"/>
 /// </summary>
 public static int ElementCount(this ITimeSpaceValueSet values)
 {
     return(ValueSet.GetElementCount(values));
 }