using Caliburn.Micro; using RMWPFUserInterface.Helpers; using RMWPFUserInterface.ViewModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; namespace RMWPFUserInterface { internal class BootStrapper : BootstrapperBase { private SimpleContainer _container = new SimpleContainer(); public BootStrapper() { Initialize(); ConventionManager.AddElementConvention( PasswordBoxHelper.BoundPasswordProperty, "Password", "PasswordChanged"); } protected override void Configure() { _container.Instance(_container); _container .Singleton() .Singleton() .Singleton(); GetType().Assembly.GetTypes() .Where(type => type.IsClass) .Where(type => type.Name.EndsWith("ViewModel")) .ToList() .ForEach(viewModelType => _container.RegisterPerRequest( viewModelType, viewModelType.ToString(), viewModelType)); } protected override void OnStartup(object sender, StartupEventArgs e) { DisplayRootViewForAsync(); } protected override object GetInstance(Type service, string key) { return _container.GetInstance(service, key); } protected override IEnumerable GetAllInstances(Type service) { return _container.GetAllInstances(service); } protected override void BuildUp(object instance) { _container.BuildUp(instance); } } }