/// <summary> /// Constructor /// </summary> /// <param name="expression">should be the of the function</param> /// <param name="parsingContext"></param> /// <param name="isNegated">True if the numeric result of the function should be negated.</param> public FunctionExpression(string expression, ParsingContext parsingContext, bool isNegated) : base(expression) { _parsingContext = parsingContext; _functionCompilerFactory = new FunctionCompilerFactory(parsingContext.Configuration.FunctionRepository); _isNegated = isNegated; base.AddChild(new FunctionArgumentExpression(this)); }
public void CreateHandlesErrorFunctionCompiler() { var functionRepository = FunctionRepository.Create(); var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context); var function = new IsError(); var functionCompiler = functionCompilerFactory.Create(function); Assert.IsInstanceOfType(functionCompiler, typeof(ErrorHandlingFunctionCompiler)); }
public void CreateHandlesLookupFunctionCompiler() { var functionRepository = FunctionRepository.Create(); var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context); var function = new Column(); var functionCompiler = functionCompilerFactory.Create(function); Assert.IsInstanceOfType(functionCompiler, typeof(LookupFunctionCompiler)); }
public void CreateHandlesSpecialIfNaCompiler() { var functionRepository = FunctionRepository.Create(); var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context); var function = new IfNa(); var functionCompiler = functionCompilerFactory.Create(function); Assert.IsInstanceOfType(functionCompiler, typeof(IfNaFunctionCompiler)); }
public void CreateHandlesStandardFunctionCompiler() { var functionRepository = FunctionRepository.Create(); var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context); var function = new Sum(); var functionCompiler = functionCompilerFactory.Create(function); Assert.IsInstanceOfType(functionCompiler, typeof(DefaultCompiler)); }
public void CreateHandlesCustomFunctionCompiler() { var functionRepository = FunctionRepository.Create(); functionRepository.LoadModule(new TestFunctionModule(_context)); var functionCompilerFactory = new FunctionCompilerFactory(functionRepository, _context); var function = new MyFunction(); var functionCompiler = functionCompilerFactory.Create(function); Assert.IsInstanceOfType(functionCompiler, typeof(MyFunctionCompiler)); }
public override bool Handle(string funcName, IEnumerable <Expression> children, ParsingContext context, out ExcelFunction function) { function = null; if (funcName.Contains(":OFFSET")) { var functionCompilerFactory = new FunctionCompilerFactory(context.Configuration.FunctionRepository, context); var startRange = funcName.Split(':')[0]; var c = context.Scopes.Current; var resultRange = context.ExcelDataProvider.GetRange(c.Address.Worksheet, c.Address.FromRow, c.Address.FromCol, startRange); var rangeOffset = new RangeOffset { StartRange = resultRange }; var compiler = functionCompilerFactory.Create(new Offset()); children.First().Children.First().IgnoreCircularReference = true; var compileResult = compiler.Compile(children); rangeOffset.EndRange = compileResult.Result as ExcelDataProvider.IRangeInfo; function = rangeOffset; return(true); } return(false); }