Пример #1
0
        /// <summary>
        /// Initializes a new instance of <see cref="BootContainer"/>
        /// </summary>
        /// <param name="bindings"><see cref="IBindingCollection">Bindings</see> for the <see cref="BootContainer"/></param>
        /// <param name="newBindingsNotifier"><see cref="ICanNotifyForNewBindings">Notifier</see> of new <see cref="Binding">bindings</see></param>
        public BootContainer(IBindingCollection bindings, ICanNotifyForNewBindings newBindingsNotifier)
        {
            _bindings = ConvertBindings(bindings);
            _bindings[typeof(IContainer)] = this;

            newBindingsNotifier.SubscribeTo(_ => ConvertBindings(_).ForEach(_bindings.Add));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BootContainer"/> class.
        /// </summary>
        /// <param name="bindings"><see cref="IBindingCollection">Bindings</see> for the <see cref="BootContainer"/>.</param>
        /// <param name="newBindingsNotifier"><see cref="ICanNotifyForNewBindings">Notifier</see> of new <see cref="Binding">bindings</see>.</param>
        public BootContainer(IBindingCollection bindings, ICanNotifyForNewBindings newBindingsNotifier)
        {
            _bindings = bindings.ToDictionary(_ => _.Service, _ => _.Strategy);

            _bindings[typeof(IContainer)]   = new Strategies.Constant(this);
            _bindings[typeof(GetContainer)] = new Strategies.Constant((GetContainer)(() => this));

            newBindingsNotifier.SubscribeTo(_ => _.ToDictionary(_ => _.Service, _ => _.Strategy).ForEach(_bindings.Add));
        }