2022-07-27 14:57:33 +02:00
|
|
|
|
using AutoMapper;
|
|
|
|
|
using Caliburn.Micro;
|
2022-07-22 16:45:33 +02:00
|
|
|
|
using RMWPFInterfaceLibrary.Api;
|
2022-07-23 23:56:50 +02:00
|
|
|
|
using RMWPFInterfaceLibrary.Helpers;
|
2022-07-22 16:45:33 +02:00
|
|
|
|
using RMWPFInterfaceLibrary.Models;
|
2022-07-08 16:27:24 +02:00
|
|
|
|
using RMWPFUserInterface.Helpers;
|
2022-07-27 14:57:33 +02:00
|
|
|
|
using RMWPFUserInterface.Models;
|
2022-07-04 18:48:43 +02:00
|
|
|
|
using RMWPFUserInterface.ViewModels;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
2022-07-08 16:27:24 +02:00
|
|
|
|
using System.Windows.Controls;
|
2022-07-04 18:48:43 +02:00
|
|
|
|
|
|
|
|
|
namespace RMWPFUserInterface
|
|
|
|
|
{
|
|
|
|
|
internal class BootStrapper : BootstrapperBase
|
|
|
|
|
{
|
|
|
|
|
private SimpleContainer _container = new SimpleContainer();
|
|
|
|
|
public BootStrapper()
|
|
|
|
|
{
|
|
|
|
|
Initialize();
|
2022-07-08 16:27:24 +02:00
|
|
|
|
|
|
|
|
|
ConventionManager.AddElementConvention<PasswordBox>(
|
|
|
|
|
PasswordBoxHelper.BoundPasswordProperty,
|
|
|
|
|
"Password",
|
|
|
|
|
"PasswordChanged");
|
2022-07-04 18:48:43 +02:00
|
|
|
|
}
|
|
|
|
|
protected override void Configure()
|
|
|
|
|
{
|
2022-07-27 14:57:33 +02:00
|
|
|
|
_container.Instance(ConfigureAutoMapper());
|
|
|
|
|
|
2022-07-23 17:09:13 +02:00
|
|
|
|
_container.Instance(_container)
|
2022-07-25 17:02:36 +02:00
|
|
|
|
.PerRequest<IProductEndPoint, ProductEndPoint>()
|
2022-08-20 14:23:25 +02:00
|
|
|
|
.PerRequest<ISaleEndPoint, SaleEndPoint>()
|
|
|
|
|
.PerRequest<IUserEndPoint, UserEndPoint>();
|
|
|
|
|
|
2022-07-23 23:56:50 +02:00
|
|
|
|
|
2022-07-04 18:48:43 +02:00
|
|
|
|
_container
|
|
|
|
|
.Singleton<IWindowManager, WindowManager>()
|
2022-07-08 17:31:58 +02:00
|
|
|
|
.Singleton<IEventAggregator, EventAggregator>()
|
2022-07-22 16:45:33 +02:00
|
|
|
|
.Singleton<ILoggedInUserModel, LoggedInUserModel>()
|
2022-07-23 23:56:50 +02:00
|
|
|
|
.Singleton<IConfigHelper, ConfigHelper>()
|
2022-07-08 17:31:58 +02:00
|
|
|
|
.Singleton<IAPIHelper, APIHelper>();
|
2022-07-04 18:48:43 +02:00
|
|
|
|
|
|
|
|
|
GetType().Assembly.GetTypes()
|
|
|
|
|
.Where(type => type.IsClass)
|
|
|
|
|
.Where(type => type.Name.EndsWith("ViewModel"))
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(viewModelType => _container.RegisterPerRequest(
|
|
|
|
|
viewModelType, viewModelType.ToString(), viewModelType));
|
|
|
|
|
}
|
2022-07-27 14:57:33 +02:00
|
|
|
|
|
|
|
|
|
private IMapper ConfigureAutoMapper()
|
|
|
|
|
{
|
|
|
|
|
var config = new MapperConfiguration(cfg =>
|
|
|
|
|
{
|
|
|
|
|
cfg.CreateMap<ProductModel, ProductDisplayModel>();
|
|
|
|
|
cfg.CreateMap<CartItemModel, CartItemDisplayModel>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var output = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 18:48:43 +02:00
|
|
|
|
protected override void OnStartup(object sender, StartupEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DisplayRootViewForAsync<ShellViewModel>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override object GetInstance(Type service, string key)
|
|
|
|
|
{
|
|
|
|
|
return _container.GetInstance(service, key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IEnumerable<object> GetAllInstances(Type service)
|
|
|
|
|
{
|
|
|
|
|
return _container.GetAllInstances(service);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void BuildUp(object instance)
|
|
|
|
|
{
|
|
|
|
|
_container.BuildUp(instance);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|