using System.Collections.Generic; using System.Windows; using Chernobyl.Collections.Generic; using Chernobyl.Destruction; using Chernobyl.Plugin; using Chernobyl.Dependency.Autofac; using Autofac; namespace Chernobyl.App { /// /// Interaction logic for App.xaml /// public partial class App : Application { /// /// Constructor. /// public App() { (_serviceContainer, _plugins) = _builder.LoadPlugins(); var dicts = _serviceContainer.Resolve>(); Resources.MergedDictionaries.AddRange(dicts); } /// /// Configures the application. Invoked when the event is /// raised. /// void OnStartup(object sender, StartupEventArgs e) { // Note: we create the window here rather than the constructor to ensure that the // DataTemplates from the app.xaml dictionaries are ready to go. Doing this in the // constructor will cause the expected DataTemplate to not display in the window. _serviceContainer.Resolve().Show(); } /// /// Disposes of resources when the application is shutdown. Invoked when the /// event is raised. /// void OnExit(object sender, ExitEventArgs e) { _plugins.Dispose(); _serviceContainer.Dispose(); } // Provides dependency injection services. readonly ContainerBuilder _builder = new ContainerBuilder(); // Services loaded from this app and the plugin modules. readonly IContainer _serviceContainer; // Plugins loaded from the modules. readonly IEnumerable> _plugins; } }