public TimeSeriesValues(RegularTimeSeriesRawData d, Frequency frequency, AttributesMap<int> keys, AttributesMap<object> attributes, Series<DateTime, double> values)
			: base(frequency, keys, attributes)
		{
			StartDate = d.StartDate;
			EndDate = d.EndDate;
			Unit = d.Unit;
			Scale = d.Scale;
			Mnemonics = d.Mnemonics;
			Values = values;
		}
        public void Add(RegularTimeSeriesRawData item)
        {
            var dimensions = new string[_dimensions.Length];
            var attributes = new object[_attributes.Length];

            foreach (var dim in item.Dimensions)
            {
                var dimIndex = _dimensionIdsMap[dim.DimensionId];
                dimensions[dimIndex] = dim.Key;
                attributes[dimIndex] = dim.Name;
                _dimensionKeyMaps[dimIndex][dim.Name] = dim.Key;
            }

            if (item.TimeSeriesAttributes != null)
            {
                foreach (var attr in item.TimeSeriesAttributes)
                {
                    var attrIndex = _attributeIds[attr.Key];
                    attributes[attrIndex] = attr.Value;
                }
            }

            var frequency  = item.Frequency.ToFrequency();
            var rangeTuple = Tuple.Create(item.StartDate, item.EndDate, frequency);
            IReadOnlyList <DateTime> timeRange;

            if (!_timeRangeCache.TryGetValue(rangeTuple, out timeRange))
            {
                timeRange = TimeFormat.InvariantTimeFormat.ExpandRangeSelection(item.StartDate, item.EndDate, frequency);
                _timeRangeCache[rangeTuple] = timeRange;
            }

            var valuesBuilder = new SeriesBuilder <DateTime, double>();
            int valueIndex    = 0;

            foreach (var valueItem in item.Values)
            {
                if (valueItem != null)
                {
                    valuesBuilder.Add(timeRange[valueIndex], Convert.ToDouble(valueItem));
                }
                valueIndex++;
            }

            var values = new TimeSeriesValues(
                item,
                frequency,
                new AttributesMap <string>(_dimensions, dimensions),
                new AttributesMap <object>(_attributes, attributes),
                valuesBuilder.Series);

            _values[values] = values;
        }