static void AssertValidType(TimeSeriesRangeType type, TimeValue time)
            {
                switch (type)
                {
                case TimeSeriesRangeType.None:
                    throw new InvalidOperationException($"Time range type cannot be set to '{nameof(TimeSeriesRangeType.None)}' when time is specified.");

                case TimeSeriesRangeType.Last:
                    if (time != default)
                    {
                        if (time.Value <= 0)
                        {
                            throw new InvalidOperationException($"Time range type cannot be set to '{nameof(TimeSeriesRangeType.Last)}' when time is negative or zero.");
                        }

                        return;
                    }

                    throw new InvalidOperationException($"Time range type cannot be set to '{nameof(TimeSeriesRangeType.Last)}' when time is not specified.");

                default:
                    throw new NotSupportedException($"Not supported time range type '{type}'.");
                }
                ;
            }
Exemple #2
0
        public void AddTimeSeries(string timeseries, TimeSeriesRangeType type, int count, string sourcePath = null)
        {
            var key = sourcePath ?? string.Empty;

            if (TimeSeries.TryGetValue(key, out var hashSet) == false)
            {
                TimeSeries[key] = hashSet = new HashSet <AbstractTimeSeriesRange>(AbstractTimeSeriesRangeComparer.Instance);
            }

            hashSet.Add(new TimeSeriesCountRange
            {
                Name  = timeseries,
                Count = count,
                Type  = type
            });
        }
        private void IncludeTimeSeriesByRangeTypeAndTime(string alias, string name, TimeSeriesRangeType type, TimeValue time)
        {
            AssertValid(alias, name);
            AssertValidType(type, time);

            if (TimeSeriesToIncludeBySourceAlias == null)
            {
                TimeSeriesToIncludeBySourceAlias = new Dictionary <string, HashSet <AbstractTimeSeriesRange> >();
            }

            if (TimeSeriesToIncludeBySourceAlias.TryGetValue(alias, out var hashSet) == false)
            {
                TimeSeriesToIncludeBySourceAlias[alias] = hashSet = new HashSet <AbstractTimeSeriesRange>(comparer: AbstractTimeSeriesRangeComparer.Instance);
            }

            hashSet.Add(new TimeSeriesTimeRange
            {
                Name = name,
                Time = time,
                Type = type
            });
 ISubscriptionIncludeBuilder <T> IAbstractTimeSeriesIncludeBuilder <T, ISubscriptionIncludeBuilder <T> > .IncludeAllTimeSeries(TimeSeriesRangeType type, int count)
 {
     IncludeTimeSeriesByRangeTypeAndCount(string.Empty, Constants.TimeSeries.All, type, count);
     return(this);
 }
 ISubscriptionIncludeBuilder <T> IAbstractTimeSeriesIncludeBuilder <T, ISubscriptionIncludeBuilder <T> > .IncludeAllTimeSeries(TimeSeriesRangeType type, TimeValue time)
 {
     IncludeTimeSeriesByRangeTypeAndTime(string.Empty, Constants.TimeSeries.All, type, time);
     return(this);
 }
 ISubscriptionIncludeBuilder <T> IAbstractTimeSeriesIncludeBuilder <T, ISubscriptionIncludeBuilder <T> > .IncludeTimeSeries(string[] names, TimeSeriesRangeType type, int count)
 {
     IncludeArrayOfTimeSeriesByRangeTypeAndCount(names, type, count);
     return(this);
 }
 ISubscriptionIncludeBuilder <T> IAbstractTimeSeriesIncludeBuilder <T, ISubscriptionIncludeBuilder <T> > .IncludeTimeSeries(string[] names, TimeSeriesRangeType type, TimeValue time)
 {
     IncludeArrayOfTimeSeriesByRangeTypeAndTime(names, type, time);
     return(this);
 }
 ISubscriptionIncludeBuilder <T> IAbstractTimeSeriesIncludeBuilder <T, ISubscriptionIncludeBuilder <T> > .IncludeTimeSeries(string name, TimeSeriesRangeType type, int count)
 {
     IncludeTimeSeriesByRangeTypeAndCount(string.Empty, name, type, count);
     return(this);
 }
 ISubscriptionIncludeBuilder <T> IAbstractTimeSeriesIncludeBuilder <T, ISubscriptionIncludeBuilder <T> > .IncludeTimeSeries(string name, TimeSeriesRangeType type, TimeValue time)
 {
     IncludeTimeSeriesByRangeTypeAndTime(string.Empty, name, type, time);
     return(this);
 }