mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-10 00:43:03 +00:00
Migrate to Stylet and refactor view/view-model framework
This commit is contained in:
@@ -1,26 +1,24 @@
|
||||
using CommonServiceLocator;
|
||||
using DiscordChatExporter.Core.Services;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
using DiscordChatExporter.Core.Services;
|
||||
using StyletIoC;
|
||||
|
||||
namespace DiscordChatExporter.Cli
|
||||
{
|
||||
public class Container
|
||||
public static class Container
|
||||
{
|
||||
public Container()
|
||||
{
|
||||
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
|
||||
SimpleIoc.Default.Reset();
|
||||
public static IContainer Instance { get; }
|
||||
|
||||
// Services
|
||||
SimpleIoc.Default.Register<IDataService, DataService>();
|
||||
SimpleIoc.Default.Register<IExportService, ExportService>();
|
||||
SimpleIoc.Default.Register<ISettingsService, SettingsService>();
|
||||
SimpleIoc.Default.Register<IUpdateService, UpdateService>();
|
||||
}
|
||||
|
||||
public T Resolve<T>(string key = null)
|
||||
static Container()
|
||||
{
|
||||
return ServiceLocator.Current.GetInstance<T>(key);
|
||||
var builder = new StyletIoCBuilder();
|
||||
|
||||
// Autobind services in the .Core assembly
|
||||
builder.Autobind(typeof(DataService).Assembly);
|
||||
|
||||
// Bind settings as singleton
|
||||
builder.Bind<SettingsService>().ToSelf().InSingletonScope();
|
||||
|
||||
// Set instance
|
||||
Instance = builder.BuildContainer();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user