1
0
mirror of synced 2024-11-14 17:33:49 +00:00
PettingZoo/App.xaml.cs

45 lines
1.2 KiB
C#
Raw Normal View History

2016-06-18 18:30:12 +00:00
using System.Linq;
using System.Reflection;
using System.Windows;
using PettingZoo.Model;
using PettingZoo.View;
using SimpleInjector;
2016-06-18 14:50:32 +00:00
namespace PettingZoo
{
public partial class App
2016-06-18 14:50:32 +00:00
{
2016-06-18 18:30:12 +00:00
public void ApplicationStartup(object sender, StartupEventArgs e)
{
var container = Bootstrap();
RunApplication(container);
}
private static Container Bootstrap()
{
var container = new Container();
container.Register<IConnectionFactory, RabbitMQClientConnectionFactory>();
container.Register<IConnectionInfoBuilder, WindowConnectionInfoBuilder>();
// Automatically register all Window and BaseViewModel descendants
foreach (var type in Assembly.GetExecutingAssembly().GetExportedTypes()
.Where(t => t.IsSubclassOf(typeof(Window)) ||
2016-06-18 18:30:12 +00:00
t.IsSubclassOf(typeof(Infrastructure.BaseViewModel))))
{
container.Register(type);
}
return container;
}
private static void RunApplication(Container container)
{
var mainWindow = container.GetInstance<MainWindow>();
mainWindow.Show();
}
2016-06-18 14:50:32 +00:00
}
}