123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Ioc;
- using GDNXFD.Alert.Config.Services.Navigation;
- using Microsoft.Practices.ServiceLocation;
- namespace GDNXFD.Alert.Config.ViewModel
- {
- /// <summary>
- /// This class contains static references to all the view models in the
- /// application and provides an entry point for the bindings.
- /// </summary>
- public class ViewModelLocator
- {
- /// <summary>
- /// Initializes a new instance of the ViewModelLocator class.
- /// </summary>
- private ViewModelLocator()
- {
- ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
- SimpleIoc.Default.Reset();
- SimpleIoc.Default.Register<INavigationService, NavigationService>(true);
- SimpleIoc.Default.Register<MainViewModel>();
- SimpleIoc.Default.Register<RuleListViewModel>();
- SimpleIoc.Default.Register<RuleFormViewModel>();
- SimpleIoc.Default.Register<LoginViewModel>();
- }
- public static ViewModelLocator Instance
- {
- get { return SingletonCreator.instance; }
- }
- class SingletonCreator
- {
- internal static readonly ViewModelLocator instance = new ViewModelLocator();
- }
- public MainViewModel Main
- {
- get
- {
- return ServiceLocator.Current.GetInstance<MainViewModel>();
- }
- }
- public RuleListViewModel RuleList
- {
- get
- {
- return ServiceLocator.Current.GetInstance<RuleListViewModel>();
- }
- }
- public LoginViewModel Login
- {
- get
- {
- return ServiceLocator.Current.GetInstance<LoginViewModel>();
- }
- }
- public RuleFormViewModel RuleForm
- {
- get
- {
- var vm = ServiceLocator.Current.GetInstance<RuleFormViewModel>();
- //vm.PreInit();
- return vm;
- }
- }
- public INavigationService NavService
- {
- get
- {
- return ServiceLocator.Current.GetInstance<INavigationService>();
- }
- }
- public static void Cleanup()
- {
- // TODO Clear the ViewModels
- }
- }
- }
|