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