public static async Task LoadFromAssembliesInDirectory( this KernelExtensionLoader loader, IDirectoryAccessor directory, IKernel kernel, KernelInvocationContext context, IReadOnlyList <FileInfo> additionalDependencies = null) { if (directory.RootDirectoryExists()) { context.Publish(new DisplayedValueProduced($"Loading kernel extensions in directory {directory.GetFullyQualifiedRoot().FullName}", context.Command)); var extensionDlls = directory.GetAllFiles() .Where(file => file.Extension == ".dll") .Select(directory.GetFullyQualifiedFilePath); foreach (var extensionDll in extensionDlls) { await loader.LoadFromAssembly( extensionDll, kernel, context, additionalDependencies); } context.Publish(new DisplayedValueProduced($"Loaded kernel extensions in directory {directory.GetFullyQualifiedRoot().FullName}", context.Command)); } }
public override async Task InvokeAsync(KernelInvocationContext context) { var kernelExtensionLoader = new KernelExtensionLoader(); await kernelExtensionLoader.LoadFromAssembly(AssemblyFile, context.HandlingKernel, context); }