public PipelineEnvironment(PipelineConfiguration configuration, IServiceProvider serviceProvider = null)
        {
            if (configuration is null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            Debug.WriteLineIf(serviceProvider is null, "no IServiceProvider is provided to the pipeline environment");
            Pipeline = PsiPipeline.Create(configuration.Name, configuration.DeliveryPolicy);
            var instEnvs = new List <ComponentEnvironment>();

            Instances = instEnvs;
            var pending = new List <ComponentConfiguration>(configuration.Instances);

            while (true)
            {
                //find one with all dependencies ready
                var compConfig = pending.Where(c => ReadyToInstantiate(c, instEnvs)).FirstOrDefault();
                if (compConfig is null)  //if not found
                {
                    if (pending.Count > 0)
                    {
                        throw new Exception($"{pending.Count} components cannot be instantiated because their data flow dependencies are not fulfilled.");
                    }
                    break;
                }
                pending.Remove(compConfig);
                var instance = compConfig.Instantiate(Pipeline, instEnvs, serviceProvider);
                var env      = new ComponentEnvironment(compConfig, instance);
                instEnvs.Add(env);
            }
        }
        public void Notify(object sender, ComponentEnvironment env)
        {
            Console.WriteLine($"Sender is {sender.GetType()}");

            if (env == ComponentEnvironment.Comp1_MethodA)
            {
                Console.WriteLine("Mediator triggers operations:");
                _component2.MethodC();
            }

            if (env == ComponentEnvironment.Comp2_MethodD)
            {
                Console.WriteLine("Mediator triggers operations:");
                _component1.MethodB();
                _component2.MethodC();
            }
        }