/// <summary> /// Initializes a new instance of the <see cref="Configurator"/> class. This overload /// allows passing in a <see cref="Preprocessor"/> that can be reused and pre-configured /// with directives not sourced from the script. /// </summary> /// <param name="engine">The engine to configure.</param> /// <param name="preprocessor">The preprocessor.</param> public Configurator(Engine engine, Preprocessor preprocessor) { _engine = engine; _preprocessor = preprocessor; _assemblyResolver = new AssemblyResolver(_scriptManager); AssemblyLoader = new AssemblyLoader(engine.FileSystem, engine.Assemblies, _assemblyResolver); PackageInstaller = new PackageInstaller(engine.FileSystem, AssemblyLoader); ClassCatalog = new ClassCatalog(); // Add this namespace and assembly engine.Namespaces.Add(typeof(ScriptBase).Namespace); engine.Assemblies.Add(typeof(ScriptBase).Assembly); }
internal AssemblyLoader(IReadOnlyFileSystem fileSystem, IAssemblyCollection assemblyCollection, AssemblyResolver assemblyResolver) { _fileSystem = fileSystem; _assemblyCollection = assemblyCollection; _assemblyResolver = assemblyResolver; // Get the location of the entry assembly string entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location; DirectoryPath entryAssemblyPath = entryAssemblyLocation == null ? new DirectoryPath(Environment.CurrentDirectory) : new FilePath(entryAssemblyLocation).Directory; _entryAssemblyDirectory = _fileSystem.GetDirectory(entryAssemblyPath); // Add the Core modules DirectAssemblies.Add(Assembly.GetAssembly(typeof(Engine))); }