Exemplo n.º 1
0
        public void Add(IKernel kernel)
        {
            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

            _childKernels.Add(kernel);

            KernelHierarchy.AddChildKernel(this, kernel);

            var chooseKernelCommand = new Command($"%%{kernel.Name}");

            chooseKernelCommand.Handler =
                CommandHandler.Create <KernelInvocationContext>(context =>
            {
                context.HandlingKernel = kernel;
            });

            AddDirective(chooseKernelCommand);

            RegisterForDisposal(kernel.KernelEvents.Subscribe(e =>
            {
                PublishEvent(e);
            }));

            RegisterForDisposal(kernel);
        }
Exemplo n.º 2
0
 public CompositeKernel()
 {
     Name = nameof(CompositeKernel);
     RegisterForDisposal(Disposable.Create(() => { KernelHierarchy.DeleteNode(this); }));
 }