Ejemplo n.º 1
0
 /// <summary>
 /// Indexer for accessing a specific dimension
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public IDimensionEntryResult this[IDimensionEntry key]
 {
     get
     {
         return(((IDictionary <IDimension, IDimensionEntryResult>) this)[key.Root][key]);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Return a dimension entry result by the given dimension entry
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public IDimensionEntryResult this[IDimensionEntry key]
        {
            get
            {
                IDimensionEntryResult result;
                if (this.DimensionEntry == key)
                {
                    return(this);
                }
                else if (Entries.TryGetValue(key, out result))
                {
                    return(result);
                }
                else
                {
                    if (key.Parent != null)
                    {
                        return(this[key.Parent][key]);
                    }
                    else
                    {
                        foreach (var dim in OtherDimensions)
                        {
                            if (dim.Key.Dimension == key.Root)
                            {
                                return(dim.Value[key]);
                            }
                        }
                    }

                    throw new ArgumentOutOfRangeException("key", "key does not match dimension");
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return a dimension entry result by the given dimension entry
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public IDimensionResult <TFact> this[IDimensionEntry key]
        {
            get
            {
                if (key == null)
                {
                    throw new ArgumentNullException(nameof(key));
                }

                if (DimensionEntry == key)
                {
                    return(this);
                }

                if (Children.TryGetValue(key, out var result))
                {
                    return(result);
                }

                if (key.Parent != null)
                {
                    return(this[key.Parent][key]);
                }

                foreach (var dim in OtherDimensions)
                {
                    if (dim.Key.DimensionEntry == key.Root)
                    {
                        return(dim.Value[key]);
                    }
                }

                throw new ArgumentOutOfRangeException(nameof(key), $"{nameof(key)} does not match dimension");
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a dimension entry result
 /// </summary>
 /// <param name="e"></param>
 /// <param name="measures"></param>
 public DimensionEntryResult(IDimensionEntry e, IEnumerable <IMeasure> measures)
 {
     DimensionEntry  = e;
     Entries         = new DimensionResultEntriesDictionary();
     OtherDimensions = new DimensionResultOtherDimensionsDictionary();
     Measures        = measures;
     Values          = new MeasureResultDictionary();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new dimension result
 /// </summary>
 /// <param name="e"></param>
 /// <param name="measures"></param>
 public DimensionResult(IDimensionEntry dimensionEntry, IEnumerable <IMeasure <TFact> > measures)
 {
     DimensionEntry  = dimensionEntry;
     Children        = new Dictionary <IDimensionEntry, IDimensionResult <TFact> >();
     OtherDimensions = new Dictionary <IDimensionResult <TFact>, IDimensionResult <TFact> >();
     Measures        = measures;
     MeasureResults  = new Dictionary <IMeasure <TFact>, IMeasureResult <TFact> >();
 }
Ejemplo n.º 6
0
        public IDimensionResult <TFact> AddChild(IDimensionEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            var newResult = new DimensionResult <TDimension, TFact>(entry, Measures);

            Children[entry] = newResult;
            return(newResult);
        }
Ejemplo n.º 7
0
        public bool CheckFilter(TFact item, IDimensionEntry entry)
        {
            var classEntry = ((DimensionEntry <TDimension>)entry);

            if (Filter == null || Filter(item))
            {
                if (EndSelector == null)
                {
                    return(classEntry.InRange(Selector(item)));
                }
                else
                {
                    return(classEntry.InRange(Selector(item), EndSelector(item)));
                }
            }

            return(false);
        }
Ejemplo n.º 8
0
        private void Apply(TFact item, IDimensionEntry entry, IDimensionResult <TFact> result)
        {
            var root = ((Dimension <TDimension, TFact>)DimensionEntry.Root);

            if (!root.CheckFilter(item, entry))
            {
                return;
            }

            // Do something
            result.ProvideItemToMeasures(item);

            // All other
            result.ProvideItemToOtherDimensions(item);

            // Provide item to Children
            foreach (var child in entry.Children)
            {
                Apply(item, child, result.Children[child]);
            }
        }
Ejemplo n.º 9
0
 public static TValue Min <TValue>(this IDimensionEntry e) where TValue : IComparable
 {
     return(((DimensionEntry <TValue>)e).Min);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Indexer for accessing a specific dimension
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public new IDimensionResult <TFact> this[IDimensionEntry key] =>
 base[key?.Root][key];