How to use TransformerFactory method of NBi.Core.Transformation.TransformerFactory class

Best NBi code snippet using NBi.Core.Transformation.TransformerFactory.TransformerFactory

InstanceArgsBuilder.cs

Source:InstanceArgsBuilder.cs Github

copy

Full Screen

...81 var derivationArgs = new Dictionary<string, DerivationArgs>();82 foreach (var derivation in (obj as InstanceSettlingXml).DerivedVariables)83 {84 var transformerArgs = new TransformaterArgs() { Language = derivation.Script.Language, Code = derivation.Script.Code };85 var transformerFactory = new TransformerFactory(ServiceLocator, new Context(Variables));86 var transformer = transformerFactory.Instantiate(transformerArgs);87 transformer.Initialize(derivation.Script.Code);88 derivationArgs.Add(derivation.Name, new DerivationArgs() { Source = derivation.BasedOn, Transformer = transformer });89 }90 args = new DerivedVariableInstanceArgs()91 {92 Name = variable.Name,93 Resolver = sequenceResolver,94 Derivations = derivationArgs,95 Categories = (obj as InstanceSettlingXml).Categories,96 Traits = (obj as InstanceSettlingXml).Traits.ToDictionary(x => x.Name, x => x.Value),97 };98 }99 }100 }101 private ISequenceResolver BuildFilterSequenceResolver(ColumnType type, ISequenceResolver resolver, FilterSequenceXml filterXml)102 {103 if (filterXml == null)104 return resolver;105 var predicateBuilder = new PredicateArgsBuilder(ServiceLocator, new Context(Variables));106 var predicateArgs = predicateBuilder.Execute(filterXml.Predication.ColumnType, filterXml.Predication.Predicate);107 var predicate = new PredicateFactory().Instantiate(predicateArgs);108 var operandTransformation = new TransformerFactory(ServiceLocator, new Context(Variables)).Instantiate109 (110 new OperandTransformation111 {112 OriginalType = type,113 Code = filterXml.Predication.Operand114 }115 );116 operandTransformation.Initialize(filterXml.Predication.Operand);117 var factory = new SequenceResolverFactory(ServiceLocator);118 return factory.Instantiate(type, new FilterSequenceResolverArgs(resolver, predicate, operandTransformation));119 }120 private class OperandTransformation : ITransformationInfo121 {122 public ColumnType OriginalType { get ; set; }...

Full Screen

Full Screen

TransformerFactoryTest.cs

Source:TransformerFactoryTest.cs Github

copy

Full Screen

...11using NBi.Core.Injection;12namespace NBi.Testing.Core.Transformation13{14 [TestFixture]15 public class TransformerFactoryTest16 {17 [Test]18 [TestCase(LanguageType.CSharp, typeof(CSharpTransformer<decimal>))]19 [TestCase(LanguageType.NCalc, typeof(NCalcTransformer<decimal>))]20 [TestCase(LanguageType.Format, typeof(FormatTransformer<decimal>))]21 [TestCase(LanguageType.Native, typeof(NativeTransformer<decimal>))]22 public void Build_Language_Correct(LanguageType language, Type result)23 {24 var info = Mock.Of<ITransformationInfo>25 (26 i => i.Language == language27 && i.OriginalType == ColumnType.Numeric28 && i.Code == "value" 29 );30 var factory = new TransformerFactory(new ServiceLocator(), null);31 var provider = factory.Instantiate(info);32 Assert.IsInstanceOf(result, provider);33 }34 [Test]35 [TestCase(ColumnType.Text, typeof(CSharpTransformer<string>))]36 [TestCase(ColumnType.Numeric, typeof(CSharpTransformer<decimal>))]37 [TestCase(ColumnType.DateTime, typeof(CSharpTransformer<DateTime>))]38 [TestCase(ColumnType.Boolean, typeof(CSharpTransformer<bool>))]39 public void Build_Language_Correct(ColumnType originalType, Type result)40 {41 var info = Mock.Of<ITransformationInfo>42 (43 i => i.Language == LanguageType.CSharp44 && i.OriginalType == originalType45 && i.Code == "value"46 );47 var factory = new TransformerFactory(new ServiceLocator(), null);48 var provider = factory.Instantiate(info);49 Assert.IsInstanceOf(result, provider);50 }51 [Test]52 [TestCase(LanguageType.NCalc, ColumnType.DateTime)]53 [TestCase(LanguageType.NCalc, ColumnType.Boolean)]54 [TestCase(LanguageType.Format, ColumnType.Text)]55 [TestCase(LanguageType.Format, ColumnType.Boolean)]56 public void Build_Language_Correct(LanguageType language, ColumnType columnType)57 {58 var info = Mock.Of<ITransformationInfo>59 (60 i => i.Language == language61 && i.OriginalType == columnType62 && i.Code == "value"63 );64 var factory = new TransformerFactory(new ServiceLocator(), null);65 Assert.Throws<InvalidOperationException>(delegate { factory.Instantiate(info); });66 }67 }68}...

Full Screen

Full Screen

TransformationProvider.cs

Source:TransformationProvider.cs Github

copy

Full Screen

...13{14 public class TransformationProvider15 {16 private IDictionary<IColumnIdentifier, ITransformer> cacheTransformers;17 private readonly TransformerFactory factory;18 private Context Context { get; }19 public TransformationProvider(ServiceLocator serviceLocator, Context context)20 {21 cacheTransformers = new Dictionary<IColumnIdentifier, ITransformer>();22 factory = new TransformerFactory(serviceLocator, context);23 Context = context;24 }25 public void Add(IColumnIdentifier indentifier, ITransformationInfo transfo)26 {27 var transformer = factory.Instantiate(transfo);28 transformer.Initialize(transfo.Code);29 if (cacheTransformers.ContainsKey(indentifier))30 throw new NBiException($"You can't define two transformers for the same column. The column {indentifier.Label} has already another transformer specified.");31 cacheTransformers.Add(indentifier, transformer);32 }33 public virtual IResultSet Transform(IResultSet resultSet)34 {35 foreach (var identifier in cacheTransformers.Keys)36 {...

Full Screen

Full Screen

TransformerFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Transformation;7{8 {9 static void Main(string[] args)10 {11 TransformerFactory factory = new TransformerFactory();12 var transformer = factory.Instantiate("C:\\Users\\Public\\Documents\\NBi\\transformations\\transformer.xslt");13 Console.WriteLine(transformer.Execute("Hello World!"));14 Console.ReadLine();15 }16 }17}

Full Screen

Full Screen

TransformerFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Xml;6using System.Xml.Linq;7using NBi.Core.Transformation;8{9 {10 static void Main(string[] args)11 {12 string xml = "<transformer type=\"upper-case\" />";13 TransformerFactory factory = new TransformerFactory();14 ITransformer transformer = factory.Instantiate(XElement.Parse(xml));15 }16 }17}18using System;19using System.Collections.Generic;20using System.Linq;21using System.Text;22using System.Xml;23using System.Xml.Linq;24using NBi.Core.Transformation;25{26 {27 static void Main(string[] args)28 {29 string xml = "<transformer type=\"lower-case\" />";30 TransformerFactory factory = new TransformerFactory();31 ITransformer transformer = factory.Instantiate(XElement.Parse(xml));32 }33 }34}35using System;36using System.Collections.Generic;37using System.Linq;38using System.Text;39using System.Xml;40using System.Xml.Linq;41using NBi.Core.Transformation;42{43 {44 static void Main(string[] args)45 {46 string xml = "<transformer type=\"left\" />";47 TransformerFactory factory = new TransformerFactory();48 ITransformer transformer = factory.Instantiate(XElement.Parse(xml));49 }50 }51}52using System;53using System.Collections.Generic;54using System.Linq;55using System.Text;56using System.Xml;57using System.Xml.Linq;58using NBi.Core.Transformation;59{60 {61 static void Main(string[] args)62 {63 string xml = "<transformer type=\"right\" />";64 TransformerFactory factory = new TransformerFactory();65 ITransformer transformer = factory.Instantiate(XElement.Parse(xml));66 }67 }68}69using System;70using System.Collections.Generic;71using System.Linq;72using System.Text;73using System.Xml;

Full Screen

Full Screen

TransformerFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.IO;3using System.Xml;4using System.Xml.Xsl;5using System.Xml.XPath;6using NBi.Core.Transformation;7{8 {9 static void Main(string[] args)10 {11 string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";12 xml += "<root>";13 xml += "<node>Value</node>";14 xml += "</root>";15 string xslt = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";16 xslt += "<xsl:template match=\"/\">";17 xslt += "<xsl:value-of select=\"root/node\" />";18 xslt += "</xsl:template>";19 xslt += "</xsl:stylesheet>";20 var factory = new TransformerFactory();21 var transformer = factory.GetTransformer(xml, xslt);22 var result = transformer.Transform();23 Console.WriteLine(result);24 Console.ReadLine();25 }26 }27}28using System;29using System.IO;30using System.Xml;31using System.Xml.Xsl;32using System.Xml.XPath;33using NBi.Core.Transformation;34{35 {36 static void Main(string[] args)37 {38 string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";39 xml += "<root>";40 xml += "<node>Value</node>";41 xml += "</root>";42 string xslt = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";43 xslt += "<xsl:template match=\"/\">";44 xslt += "<xsl:value-of select=\"root/node\" />";45 xslt += "</xsl:template>";46 xslt += "</xsl:stylesheet>";47 var factory = new TransformerFactory();48 var transformer = factory.GetTransformer(xml, xslt);49 var result = transformer.Transform();50 Console.WriteLine(result);51 Console.ReadLine();52 }53 }54}

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 TransformerFactory

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful