Ejemplo n.º 1
0
        public ExcelFunction LoadAndGetExcelFunction(string functionName)
        {
            var delegates                  = new List <Delegate>();
            var functionAttributes         = new List <object>();
            var functionArgumentAttributes = new List <List <object> >();
            var assembly = Assembly.GetAssembly(typeof(XLEquities));

            StaticData.Load();
            ExcelTypeConverter.AddConvertersFrom(Assembly.GetAssembly(typeof(AddIn)));
            FunctionRegistration.GetDelegatesAndAttributes(assembly, "QSA", new Dictionary <string, bool>(),
                                                           ref delegates, ref functionAttributes, ref functionArgumentAttributes);

            ExcelFunction func = null;

            foreach (var d in delegates)
            {
                func = (ExcelFunction)d.Target;
                if (func.GetName() == functionName)
                {
                    return(func);
                }
            }

            throw new InvalidOperationException($"{functionName} is not an available Excel function.");
        }