How to use Instantiate method of NBi.Core.Sequence.Transformation.Aggregation.AggregationFactory class

Best NBi code snippet using NBi.Core.Sequence.Transformation.Aggregation.AggregationFactory.Instantiate

SummarizeEngine.cs

Source:SummarizeEngine.cs Github

copy

Full Screen

...30 foreach (var aggregation in Args.Aggregations)31 {32 var columnName = ExtractColumnName(rs, aggregation);33 dataTable.Columns.Add(new DataColumn(columnName, MapType(aggregation.Function, aggregation.ColumnType)));34 aggregations.Add(factory.Instantiate(aggregation));35 }36 var groupbyFactory = new GroupByFactory();37 var groupbyEngine = groupbyFactory.Instantiate(new ColumnGroupByArgs(Args.GroupBys, Context.None));38 var groups = groupbyEngine.Execute(rs);39 foreach (var group in groups)40 {41 var values = new List<object>();42 values.AddRange(group.Key.Members);43 foreach (var aggregation in aggregations.Zip(Args.Aggregations, (x, y) => new { Implementation = x, Definition = y }))44 {45 var inputs = new List<object>();46 foreach (DataRow groupRow in group.Value.Rows)47 if (aggregation.Definition.Identifier == null)48 inputs.Add(1);49 else50 inputs.Add(groupRow.GetValue(aggregation.Definition.Identifier));51 var aggrResult = aggregation.Implementation.Execute(inputs);...

Full Screen

Full Screen

AggregationFactoryTest.cs

Source:AggregationFactoryTest.cs Github

copy

Full Screen

...19 [TestCase(ColumnType.Numeric, AggregationFunctionType.Min, typeof(MinNumeric))]20 [TestCase(ColumnType.Numeric, AggregationFunctionType.Max, typeof(MaxNumeric))]21 [TestCase(ColumnType.DateTime, AggregationFunctionType.Min, typeof(MinDateTime))]22 [TestCase(ColumnType.DateTime, AggregationFunctionType.Max, typeof(MaxDateTime))]23 public void Instantiate_ColumnTypeandAggregationFunction_CorrectAggregation(ColumnType columnType, AggregationFunctionType function, Type expectedType)24 {25 var factory = new AggregationFactory();26 var aggregation = factory.Instantiate(columnType, function, Array.Empty<IScalarResolver>(), Array.Empty<IAggregationStrategy>());27 Assert.That(aggregation, Is.Not.Null);28 Assert.That(aggregation.Function, Is.TypeOf(expectedType));29 }30 [Test]31 [TestCase(ColumnType.Numeric)]32 [TestCase(ColumnType.Boolean)]33 [TestCase(ColumnType.DateTime)]34 [TestCase(ColumnType.Text)]35 public void Instantiate_ColumnTypeCount_CorrectAggregation(ColumnType columnType)36 {37 var factory = new AggregationFactory();38 var aggregation = factory.Instantiate(columnType, AggregationFunctionType.Count, Array.Empty<IScalarResolver>(), Array.Empty<IAggregationStrategy>());39 Assert.That(aggregation, Is.Not.Null);40 Assert.That(aggregation.Function, Is.InstanceOf<Count>());41 }42 [Test]43 public void Instantiate_ConcantenationText_CorrectAggregation()44 {45 var factory = new AggregationFactory();46 var aggregation = factory.Instantiate(ColumnType.Text, AggregationFunctionType.Concatenation, new List<IScalarResolver> { new LiteralScalarResolver<string>("+")}.ToArray(), Array.Empty<IAggregationStrategy>());47 Assert.That(aggregation, Is.Not.Null);48 Assert.That(aggregation.Function, Is.TypeOf<ConcatenationText>());49 }50 [TestCase(ColumnType.DateTime, AggregationFunctionType.Sum)]51 [TestCase(ColumnType.DateTime, AggregationFunctionType.Average)]52 public void Instantiate_ColumnTypeAndAggregationFunction_CorrectAggregation(ColumnType columnType, AggregationFunctionType function)53 {54 var factory = new AggregationFactory();55 Assert.Throws<ArgumentException>( () => factory.Instantiate(columnType, function, Array.Empty<IScalarResolver>(), Array.Empty<IAggregationStrategy>()));56 }57 }58}...

Full Screen

Full Screen

AggregationFactory.cs

Source:AggregationFactory.cs Github

copy

Full Screen

...11namespace NBi.Core.Sequence.Transformation.Aggregation12{13 public class AggregationFactory14 {15 public Aggregation Instantiate(ColumnType columnType, AggregationFunctionType function, IScalarResolver[] parameters, IAggregationStrategy[] strategies)16 {17 var missingValue = (IMissingValueStrategy)(strategies.SingleOrDefault(x => x is IMissingValueStrategy) ?? new DropStrategy(columnType));18 var emptySeries = (IEmptySeriesStrategy)(strategies.SingleOrDefault(x => x is IEmptySeriesStrategy) ?? new ReturnDefaultStrategy(columnType));19 var @namespace = $"{this.GetType().Namespace}.Function.";20 var typeName = $"{Enum.GetName(typeof(AggregationFunctionType), function)}{Enum.GetName(typeof(ColumnType), columnType)}";21 var type = GetType().Assembly.GetType($"{@namespace}{typeName}", false, true) ?? throw new ArgumentException($"No aggregation named '{typeName}' has been found in the namespace '{@namespace}'.");22 if ((parameters?.Count() ?? 0) == 0)23 return new Aggregation((IAggregationFunction)(type.GetConstructor(Type.EmptyTypes).Invoke(Array.Empty<object>())), missingValue, emptySeries);24 else25 {26 var ctor = type.GetConstructors().Where(x => x.IsPublic && (x.GetParameters().Count() == parameters.Count())).FirstOrDefault()27 ?? throw new ArgumentException($"No public constructor for the aggregation '{function}' expecting {parameters.Count()} parameters.");28 return new Aggregation((IAggregationFunction)ctor.Invoke(parameters), missingValue, emptySeries);29 }30 }31 public Aggregation Instantiate(AggregationArgs args)32 => Instantiate(args.ColumnType, args.Function, args.Parameters.ToArray(), args.Strategies.ToArray());33 }34}...

Full Screen

Full Screen

Instantiate

Using AI Code Generation

copy

Full Screen

1var factory = new AggregationFactory();2var aggregate = factory.Instantiate("aggregate", new[] { "column1" });3var factory = new AggregationFactory();4var aggregate = factory.Instantiate("aggregate", new[] { "column1" });5var factory = new AggregationFactory();6var aggregate = factory.Instantiate("aggregate", new[] { "column1" });7var factory = new AggregationFactory();8var aggregate = factory.Instantiate("aggregate", new[] { "column1" });9var factory = new AggregationFactory();10var aggregate = factory.Instantiate("aggregate", new[] { "column1" });11var factory = new AggregationFactory();12var aggregate = factory.Instantiate("aggregate", new[] { "column1" });13var factory = new AggregationFactory();14var aggregate = factory.Instantiate("aggregate", new[] { "column1" });15var factory = new AggregationFactory();16var aggregate = factory.Instantiate("aggregate", new[] { "column1" });17var factory = new AggregationFactory();18var aggregate = factory.Instantiate("aggregate", new[] { "column1" });19var factory = new AggregationFactory();20var aggregate = factory.Instantiate("aggregate", new[] { "column1" });21var factory = new AggregationFactory();22var aggregate = factory.Instantiate("aggregate", new[] { "column1" });

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in AggregationFactory

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful