Files
quantconnect--lean/Research/Initialize.csx
T
Colton Sellers a882aadeef
Build & Test Lean / build (push) Has been cancelled
Research Fixes and Doc Updates (#5649)
* Updates to default notebooks

* Update readme

* Notebook adjustments

* Drop launch script support

* Use our cwd if no QC dlls are in AppDomain directory

* Modify Intialize.csx to use parent directory only if QC files are detected there

* Clean up some details after testing

* Adjustments

* nit, NullOrWhiteSpace
2021-06-11 16:06:47 -03:00

26 lines
863 B
C#

using System;
using System.IO;
using System.Linq;
using System.Reflection;
var currentDirectory = Directory.GetCurrentDirectory();
var parentDirectory = Directory.GetParent(currentDirectory).FullName;
// If our parent directory contains QC Dlls use it, otherwise default to current working directory
// In cloud and CLI research cases we expect the parent directory to contain the Dlls; but locally it may be cwd
var directoryToLoad = Directory.GetFiles(parentDirectory, "QuantConnect.*.dll").Any() ? parentDirectory : currentDirectory;
// Load in all dll's from this directory
Console.WriteLine($"Initialize.csx: Loading assemblies from {directoryToLoad}");
foreach (var file in Directory.GetFiles(directoryToLoad, "*.dll"))
{
try
{
Assembly.LoadFrom(file.ToString());
}
catch (Exception e)
{
Console.WriteLine(e);
}
}