public ISummaryRepositoryItem ProduceFor(ServerModeSummaryDescriptor summaryDescriptor)
        {
            var summaryType = summaryDescriptor.SummaryType;

            switch (summaryType)
            {
            case Aggregate.Avg:
                return(ProduceAVGItem(summaryDescriptor));

            case Aggregate.Count:
                return(ProduceSimpleItem(summaryDescriptor));

            case Aggregate.Min:
                return(ProduceSimpleItem(summaryDescriptor));

            case Aggregate.Max:
                return(ProduceSimpleItem(summaryDescriptor));

            case Aggregate.Sum:
                return(ProduceSimpleItem(summaryDescriptor));

            default:
                throw new NotSupportedException("Не поддерживаем SummaryType отличный от 'Avg', 'Count', 'Min', 'Max', 'Sum'. Переданное значение SummaryType: '{0}'".FillWith(summaryType));
            }
        }
Exemple #2
0
        public SummaryRepositoryItemsContext(ServerModeSummaryDescriptor itemsDescriptor)
        {
            ItemsDescriptor = itemsDescriptor;

            ItemsType = CalculateItemsType(ItemsDescriptor);

            Key = ItemsDescriptor.CalculateKey();
        }
        public SummaryRepositoryItemsContext(ServerModeSummaryDescriptor itemsDescriptor)
        {
            ItemsDescriptor = itemsDescriptor;

            ItemsType = CalculateItemsType(ItemsDescriptor);

            Key = ItemsDescriptor.CalculateKey();
        }
        private SimpleSummaryRepositoryItem ProduceSimpleItem(ServerModeSummaryDescriptor sourceDescriptor)
        {
            var itemValue = DataSourceEnumerator.FetchNext();

            return(new SimpleSummaryRepositoryItem(sourceDescriptor)
            {
                Value = itemValue
            });
        }
        private AVGSummaryRepositoryItem ProduceAVGItem(ServerModeSummaryDescriptor sourceDescriptor)
        {
            var itemSum = DataSourceEnumerator.FetchNext().As<decimal>();
            var itemCount = DataSourceEnumerator.FetchNext().As<int>();

            var itemValue = itemSum / itemCount;

            return new AVGSummaryRepositoryItem(sourceDescriptor)
            {
                Sum = itemSum,
                Count = itemCount,

                Value = itemValue
            };
        }
        private AVGSummaryRepositoryItem ProduceAVGItem(ServerModeSummaryDescriptor sourceDescriptor)
        {
            var itemSum   = DataSourceEnumerator.FetchNext().As <decimal>();
            var itemCount = DataSourceEnumerator.FetchNext().As <int>();

            var itemValue = itemSum / itemCount;


            return(new AVGSummaryRepositoryItem(sourceDescriptor)
            {
                Sum = itemSum,
                Count = itemCount,

                Value = itemValue
            });
        }
Exemple #7
0
        private static Type CalculateItemsType(ServerModeSummaryDescriptor summaryDescriptor)
        {
            var summaryType = summaryDescriptor.SummaryType;

            switch (summaryType)
            {
            case Aggregate.Avg:
                return(typeof(AVGSummaryRepositoryItem));

            case Aggregate.Count:
            case Aggregate.Min:
            case Aggregate.Max:
            case Aggregate.Sum:
                return(typeof(SimpleSummaryRepositoryItem));

            default:
                throw new NotSupportedException("Не поддерживаем SummaryType отличный от 'Avg', 'Count', 'Min', 'Max', 'Sum'. Переданное значение SummaryType: '{0}'".FillWith(summaryType));
            }
        }
        public ISummaryRepositoryItem ProduceFor(ServerModeSummaryDescriptor summaryDescriptor)
        {
            var summaryType = summaryDescriptor.SummaryType;

            switch (summaryType)
            {
                case Aggregate.Avg:
                    return ProduceAVGItem(summaryDescriptor);
                case Aggregate.Count:
                    return ProduceSimpleItem(summaryDescriptor);
                case Aggregate.Min:
                    return ProduceSimpleItem(summaryDescriptor);
                case Aggregate.Max:
                    return ProduceSimpleItem(summaryDescriptor);
                case Aggregate.Sum:
                    return ProduceSimpleItem(summaryDescriptor);
                default:
                    throw new NotSupportedException("Не поддерживаем SummaryType отличный от 'Avg', 'Count', 'Min', 'Max', 'Sum'. Переданное значение SummaryType: '{0}'".FillWith(summaryType));
            }
        }
 public ISummaryRepositoryItem Produce(ServerModeSummaryDescriptor summaryDescriptor)
 {
     return ProduceFor(summaryDescriptor);
 }
 public ISummaryRepositoryItem Item(ServerModeSummaryDescriptor summaryDescriptor)
 {
     return ItemsDictionary[summaryDescriptor.CalculateKey()];
 }
 protected BaseSummaryRepositoryItem(ServerModeSummaryDescriptor sourceDescriptor)
 {
     SourceDescriptor = sourceDescriptor;
     Key = SourceDescriptor.CalculateKey();
 }
        private static Type CalculateItemsType(ServerModeSummaryDescriptor summaryDescriptor)
        {
            var summaryType = summaryDescriptor.SummaryType;

            switch (summaryType)
            {
                case Aggregate.Avg:
                    return typeof(AVGSummaryRepositoryItem);
                case Aggregate.Count:
                case Aggregate.Min:
                case Aggregate.Max:
                case Aggregate.Sum:
                    return typeof(SimpleSummaryRepositoryItem);
                default:
                    throw new NotSupportedException("Не поддерживаем SummaryType отличный от 'Avg', 'Count', 'Min', 'Max', 'Sum'. Переданное значение SummaryType: '{0}'".FillWith(summaryType));
            }
        }
 public static string CalculateKey(this ServerModeSummaryDescriptor source)
 {
     return("|" + CalculateKeyPart(source.SummaryType) + "|" + CalculateKeyPart(source.SummaryExpression) + "|");
 }
 public ISummaryRepositoryItem Produce(ServerModeSummaryDescriptor summaryDescriptor)
 {
     return(ProduceFor(summaryDescriptor));
 }
 public object Value(ServerModeSummaryDescriptor summaryDescriptor)
 {
     return Item(summaryDescriptor).Value;
 }
        private SimpleSummaryRepositoryItem ProduceSimpleItem(ServerModeSummaryDescriptor sourceDescriptor)
        {
            var itemValue = DataSourceEnumerator.FetchNext();

            return new SimpleSummaryRepositoryItem(sourceDescriptor)
            {
                Value = itemValue
            };
        }
Exemple #17
0
        public NHibernateSummaryProcessor <T> AddSummaryDesciptor(ServerModeSummaryDescriptor summaryDescriptor)
        {
            PermanentSummaryDescriptors.Add(summaryDescriptor);

            return(this);
        }
Exemple #18
0
 public bool Contains(ServerModeSummaryDescriptor summaryDescriptor)
 {
     return(ItemsDictionary.ContainsKey(summaryDescriptor.CalculateKey()));
 }
Exemple #19
0
 public ISummaryRepositoryItem Item(ServerModeSummaryDescriptor summaryDescriptor)
 {
     return(ItemsDictionary[summaryDescriptor.CalculateKey()]);
 }
Exemple #20
0
 public object Value(ServerModeSummaryDescriptor summaryDescriptor)
 {
     return(Item(summaryDescriptor).Value);
 }
 public SimpleSummaryRepositoryItem(ServerModeSummaryDescriptor sourceDescriptor)
     : base(sourceDescriptor)
 {
 }
 public AVGSummaryRepositoryItem(ServerModeSummaryDescriptor sourceDescriptor)
     : base(sourceDescriptor)
 {
 }
 protected BaseSummaryRepositoryItem(ServerModeSummaryDescriptor sourceDescriptor)
 {
     SourceDescriptor = sourceDescriptor;
     Key = SourceDescriptor.CalculateKey();
 }
 public bool Contains(ServerModeSummaryDescriptor summaryDescriptor)
 {
     return ItemsDictionary.ContainsKey(summaryDescriptor.CalculateKey());
 }