예제 #1
0
        public void AVGGeneratesCorrectJson()
        {
            var items = new List <IAVGItem>
            {
                new AVGPath
                {
                    Fill        = "red",
                    Stroke      = "blue",
                    StrokeWidth = 4,
                    PathData    = "M 50 0 L 100 50 L 50 100 L 0 50 z"
                }
            };

            var avg = new AVG
            {
                Height = 100,
                Width  = 100,
                Items  = new APLValue <IList <IAVGItem> >(items)
            };

            Assert.True(Utility.CompareJson(avg, "AVG.json"));

            var avgdeserial = Utility.ExampleFileContent <AVG>("AVG.json");
            var item        = Assert.Single(avgdeserial.Items.Value);

            Assert.IsType <AVGPath>(item);
        }
예제 #2
0
        private void aVGToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
            AVG avg = new AVG();

            avg.Show();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Delegate[] delegates = new Delegate[] { new Number(Randomizer), new Number(Randomizer), new Number(Randomizer), new Number(Randomizer), new Number(Randomizer), new Number(Randomizer), new Number(Randomizer), new Number(Randomizer), new Number(Randomizer), new Number(Randomizer) };
            AVG        avg       = (del) =>
            {
                double avgDel = 0;
                for (int i = 0; i < del.Length; i++)
                {
                    avgDel = avgDel + (Int32)del[i].DynamicInvoke();
                }
                return(avgDel / del.Length);
            };

            Console.WriteLine(avg.Invoke(delegates));
            Console.ReadLine();
        }
예제 #4
0
        public DocumentCollector AddAggregateFunction(AggregateFunctionType type, IEvaluable field)
        {
            if (_aggregations == null)
            {
                _aggregations = new List <DocumentCollector>();
            }
            IAggregation function;

            switch (type)
            {
            case AggregateFunctionType.AVG:
                function = new AVG();
                break;

            case AggregateFunctionType.COUNT:
                function = new COUNT();
                break;

            case AggregateFunctionType.MAX:
                function = new MAX();
                break;

            case AggregateFunctionType.MIN:
                function = new MIN();
                break;

            case AggregateFunctionType.SUM:
                function = new SUM();
                break;

            //case AggregateFunctionType.FIRST:
            //    function = new FIRST(field);
            //    break;
            //case AggregateFunctionType.LAST:
            //    function = new LAST(field);
            //    break;
            default:
                throw new QuerySystemException(ErrorCodes.Query.AGGREGATION_INVALID_FUNCTION);
            }
            var aggregator = new DocumentCollector(function, field);

            _aggregations.Add(aggregator);
            return(aggregator);
        }
예제 #5
0
        public void AVGGeneratesCorrectJson()
        {
            var items = new List <IAVGItem>
            {
                new AVGPath
                {
                    Fill        = "red",
                    Stroke      = "blue",
                    StrokeWidth = 4,
                    PathData    = "M 50 0 L 100 50 L 50 100 L 0 50 z"
                }
            };

            var avg = new AVG
            {
                Height = 100,
                Width  = 100,
                Items  = new APLValue <IList <IAVGItem> >(items)
            };

            Assert.True(Utility.CompareJson(avg, "AVG.json"));
        }