using System.Collections.Generic; using System.Collections.ObjectModel; using Autofac; using Chernobyl.App.Core; using Chernobyl.Creation; using Chernobyl.Creation.Collections; using Chernobyl.Dependency.Autofac; namespace Chernobyl.App.Layout { /// /// Injects the layout services. /// public class Module : Autofac.Module { /// protected override void Load(ContainerBuilder builder) { builder.BindTemplateResourceAuto(); // The collection of tools that is displayed in the toolbar. builder.Register(synt => new ObservableCollection()) .As, ICollection, ObservableCollection>() .SingleInstance(); // TODO: this code forces the factories (and the content list) to be created. We just // want factories that already exist. consider using domain events to handle this instead // https://stackoverflow.com/questions/5629676/using-autofac-with-domain-events builder.BindPlugin(); } } /// /// Listens for creation of through instances /// and stores the created in . /// public class ContentWarehouse : Warehouse { /// The list of content that has already been created. /// The instances that create the content. public ContentWarehouse(ObservableCollection content, IEnumerable> contentFactories) : base(new BuilderComposite(contentFactories), content) {} } }