Example #1
0
        public CompositeKernel()
        {
            Name             = nameof(CompositeKernel);
            _extensionLoader = new CompositeKernelExtensionLoader();
            Pipeline.AddMiddleware(async(command, context, next) =>
            {
                if (command is AddPackage _)
                {
                    var packageAddedEvents = new List <PackageAdded>();
                    using var _            = context.KernelEvents.OfType <PackageAdded>().Subscribe(packageAddedEvents.Add);

                    await next(command, context);

                    foreach (var packageRoot in packageAddedEvents.Select(p => p.PackageReference.PackageRoot)
                             .Distinct())
                    {
                        var loadExtensionsInDirectory = new LoadExtensionsInDirectory(packageRoot, Name);
                        await this.SendAsync(loadExtensionsInDirectory);
                    }
                }
                else
                {
                    await next(command, context);
                }
            });
        }
Example #2
0
 public CompositeKernel()
 {
     Name             = nameof(CompositeKernel);
     _extensionLoader = new CompositeKernelExtensionLoader();
     RegisterForDisposal(KernelEvents
                         .OfType <PackageAdded>()
                         .Distinct(pa => pa.PackageReference.PackageRoot)
                         .Subscribe(_packages.Enqueue));
 }