// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // The Castle Bootstrapper // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Startup { using System; using System.Collections.Generic; using Caliburn.Micro; using HandBrakeWPF.Services; using HandBrakeWPF.Services.Interfaces; using HandBrakeWPF.Services.Presets; using HandBrakeWPF.Services.Presets.Interfaces; using HandBrakeWPF.Services.Queue; using HandBrakeWPF.Services.Queue.Interfaces; using HandBrakeWPF.Services.Scan; using HandBrakeWPF.Services.Scan.Interfaces; using HandBrakeWPF.ViewModels; using HandBrakeWPF.ViewModels.Interfaces; using IEncode = HandBrakeWPF.Services.Encode.Interfaces.IEncode; using LibEncode = HandBrakeWPF.Services.Encode.LibEncode; /// /// The Castle Bootstrapper /// public class AppBootstrapper : BootstrapperBase { private SimpleContainer container; /// /// Initializes a new instance of the class. /// public AppBootstrapper() { this.Initialize(); } /// /// Configure Castle Windsor /// protected override void Configure() { this.container = new SimpleContainer(); this.container.Singleton(); this.container.Singleton(); // Services this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); // Commands // Services and Shell Components this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.PerRequest(); this.container.PerRequest(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); // Tab Components this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); this.container.Singleton(); // Shell this.container.Singleton(); this.container.Singleton(); base.Configure(); } /// /// The on startup. /// /// /// The sender. /// /// /// The e. /// protected override void OnStartup(object sender, System.Windows.StartupEventArgs e) { DisplayRootViewFor(); } /// /// Get an Instance of a service /// /// /// The service. /// /// /// The key. /// /// /// The Service Requested /// protected override object GetInstance(Type service, string key) { var instance = container.GetInstance(service, key); if (instance != null) { return instance; } throw new InvalidOperationException("Could not locate any instances."); } /// /// Get all instances of a service /// /// /// The service. /// /// /// A collection of instances of the requested service type. /// protected override IEnumerable GetAllInstances(Type service) { return container.GetAllInstances(service); } /// /// Build Up /// /// /// The instance. /// protected override void BuildUp(object instance) { this.container.BuildUp(instance); } } }