// Called when addin opens public void AutoOpen() { try { QuantSAState.SetLogger(new ExcelFileLogFactory()); ExcelDna.IntelliSense.IntelliSenseServer.Install(); _log = QuantSAState.LogFactory.Get(MethodBase.GetCurrentMethod().DeclaringType); var pathString = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "QuantSA"); if (!Directory.Exists(pathString)) { Directory.CreateDirectory(pathString); } //TODO: Check if newer version of addin exists. _log.Info("Loading static data"); StaticData.Load(); _log.Info("Check custom function visibility"); // Get the functions that are set for the user. var funcsInUserFile = GetFunctionVisibility(FunctionsFilenameUser); //Check in the installation folder for any dlls that include a class of type IQuantSAPlugin AssemblyImageResources = new Dictionary <string, Bitmap>(); _log.Info("Check for plugins"); GetPlugins(); var assemblies = new[] { Assembly.GetAssembly(typeof(XLEquities)), Assembly.GetAssembly(typeof(AddIn)) }; _log.Info("Add converters"); foreach (var tuple in Plugins) { ExcelTypeConverter.AddConvertersFrom(tuple.Item2); } foreach (var assembly in assemblies) { ExcelTypeConverter.AddConvertersFrom(assembly); } _log.Info("Register user functions"); foreach (var tuple in Plugins) { FunctionRegistration.RegisterFrom(tuple.Item2, tuple.Item1.GetShortName(), funcsInUserFile); } foreach (var assembly in assemblies) { FunctionRegistration.RegisterFrom(assembly, "QSA", funcsInUserFile); } UpdateUserFunctionFile(funcsInUserFile, FunctionRegistration.FunctionNames); } catch (Exception e) { _log.Error(e); var pathString = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "QuantSA"); var fileName = Path.Combine(pathString, "QuantSAError.txt"); File.WriteAllText(fileName, e.ToString()); throw new AddInException("An error occurred while opening the QuantSA addin.\n" + "Check the error log file for details.\n\n" + $"{fileName}"); } }
public void TestInitialize() { QuantSAState.SetLogger(new TestLogger()); }