private FunctionCompiler GetCompilerByType(ExcelFunction function) { var funcType = function.GetType(); if (_specialCompilers.ContainsKey(funcType)) { return _specialCompilers[funcType]; } return new DefaultCompiler(function); }
/// <summary> /// Adds or replaces a function. /// </summary> /// <param name="functionName"> Case-insensitive name of the function that should be added or replaced.</param> /// <param name="functionImpl">An implementation of an <see cref="ExcelFunction"/>.</param> public void AddOrReplaceFunction(string functionName, ExcelFunction functionImpl) { Require.That(functionName).Named("functionName").IsNotNullOrEmpty(); Require.That(functionImpl).Named("functionImpl").IsNotNull(); var fName = functionName.ToLower(); if (_functions.ContainsKey(fName)) { _functions.Remove(fName); } _functions[fName] = functionImpl; }
/// <summary> /// Adds or replaces a function. /// </summary> /// <param name="functionName"> Case-insensitive name of the function that should be added or replaced.</param> /// <param name="functionImpl">An implementation of an <see cref="ExcelFunction"/>.</param> public void AddOrReplaceFunction(string functionName, ExcelFunction functionImpl) { Require.That(functionName).Named("functionName").IsNotNullOrEmpty(); Require.That(functionImpl).Named("functionImpl").IsNotNull(); var fName = functionName.ToLower(CultureInfo.InvariantCulture); if (_functions.ContainsKey(fName)) { _functions.Remove(fName); } _functions[fName] = functionImpl; }
/// <summary> /// If the supplied <paramref name="functionName"/> does not exist, the supplied /// <paramref name="functionImpl"/> implementation will be added to the formula parser. /// If it exists, the existing function will be replaced by the supplied <paramref name="functionImpl">function implementation</paramref> /// </summary> /// <param name="functionName"></param> /// <param name="functionImpl"></param> public void AddOrReplaceFunction(string functionName, ExcelFunction functionImpl) { _parser.Configure(x => x.FunctionRepository.AddOrReplaceFunction(functionName, functionImpl)); }
public IfFunctionCompiler(ExcelFunction function) : base(function) { Require.That(function).Named("function").IsNotNull(); if (!(function is If)) throw new ArgumentException("function must be of type If"); }
public DefaultCompiler(ExcelFunction function) : base(function) { }
public FunctionCompiler(ExcelFunction function) { Require.That(function).Named("function").IsNotNull(); Function = function; }
public LookupFunctionCompiler(ExcelFunction function) : base(function) { }
public ErrorHandlingFunctionCompiler(ExcelFunction function) : base(function) { }
public IfNaFunctionCompiler(ExcelFunction function) : base(function) { }
public IfErrorFunctionCompiler(ExcelFunction function) : base(function) { Require.That(function).Named("function").IsNotNull(); }
public virtual FunctionCompiler Create(ExcelFunction function) { if (function.IsLookupFuction) return new LookupFunctionCompiler(function); if (function.IsErrorHandlingFunction) return new ErrorHandlingFunctionCompiler(function); return GetCompilerByType(function); }