public LoginViewViewModel(IViewAwareStatus viewAwareStatus, IAuthenticateService authenticateService, IMessageBoxService messageBoxService, IBusinessUnitService businessUnitService, IViewInjectionService viewInjectionService) { //base.IsCloseable = true; //Initialise Services this.viewAwareStatus = viewAwareStatus; this.authenticateService = authenticateService; this.messageBoxService = messageBoxService; this.businessUnitService = businessUnitService; this.viewInjectionService = viewInjectionService; //this.regionManager = regionManager; //Initialise Properties UserName = new DataWrapper <string>(this, userNameArgs); Password = new DataWrapper <string>(this, passwordArgs); SelectedBusinessUnit = new DataWrapper <Int32>(this, businessUnitsArgs); this.viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded); cachedListOfDataWrappers = DataWrapperHelper.GetWrapperProperties <LoginViewViewModel>(this); //Register Mediator Mediator.Instance.Register(this); //Initialise Rules userName.AddRule(UserNameCannnotBeEmptyRule); password.AddRule(PasswordCannotBeEmptyRule); selectedBusinessUnit.AddRule(SelectedBusinessUnitCannotBeEmpty); //Initialise Commands LoginCommand = new SimpleCommand <object, object>(CanExecuteLoginCommand, ExecuteLoginCommand); CancelLoginCommand = new SimpleCommand <object, object>(ExecuteCancelLoginCommand); }
static void VerifyService(IViewInjectionService service) { if (service == null) { throw new ArgumentNullException("service"); } }
public void NullServiceTest() { IViewInjectionService iService = null; AssertHelper.AssertThrows <ArgumentNullException>(() => { iService.Inject(null, null); }); AssertHelper.AssertThrows <ArgumentNullException>(() => { iService.Inject(null, null, string.Empty); }); AssertHelper.AssertThrows <ArgumentNullException>(() => { iService.Inject(null, null, typeof(string)); }); AssertHelper.AssertThrows <ArgumentNullException>(() => { iService.GetViewModel(null); }); }
public ViewAllUsersViewViewModel(IMessageBoxService messageBoxService, IViewAwareStatus viewAwareStatus, IViewInjectionService viewInjectionService, IUserService userService) { this.messageBoxService = messageBoxService; this.viewAwareStatus = viewAwareStatus; this.userService = userService; this.viewInjectionService = viewInjectionService; Mediator.Instance.Register(this); viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded); }
public UserRibbonViewViewModel(IMessageBoxService messageBoxService, IViewAwareStatus viewAwareStatus, IViewInjectionService viewInjectionService) { this.messageBoxService = messageBoxService; this.viewAwareStatus = viewAwareStatus; this.viewInjectionService = viewInjectionService; Mediator.Instance.Register(this); //Initialise Commands AddNewUserCommand = new SimpleCommand<object, object>(CanExecuteAddNewUserCommand, ExecuteAddNewUserCommand); ViewAllUsersCommand = new SimpleCommand<object, object>(CanExecuteViewAllUsersCommand, ExecuteViewAllUsersCommand); }
public virtual void UnregisterService(IViewInjectionService service) { ServiceManager.Remove(service); if (Mode == ViewInjectionMode.Persistent) { foreach (object vm in service.ViewModels.ToList()) { service.Remove(vm); } } }
public UserRibbonViewViewModel(IMessageBoxService messageBoxService, IViewAwareStatus viewAwareStatus, IViewInjectionService viewInjectionService) { this.messageBoxService = messageBoxService; this.viewAwareStatus = viewAwareStatus; this.viewInjectionService = viewInjectionService; Mediator.Instance.Register(this); //Initialise Commands AddNewUserCommand = new SimpleCommand <object, object>(CanExecuteAddNewUserCommand, ExecuteAddNewUserCommand); ViewAllUsersCommand = new SimpleCommand <object, object>(CanExecuteViewAllUsersCommand, ExecuteViewAllUsersCommand); }
public MainViewViewModel(IViewAwareStatus viewAwareStatus, IMessageBoxService messageBoxService, IViewInjectionService viewInjectionService) { //this.regionManager = regionManager; this.viewAwareStatus = viewAwareStatus; this.messageBoxService = messageBoxService; this.viewInjectionService = viewInjectionService; this.viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded); //Listen for login event Mediator.Instance.Register(this); LogoutCommand = new SimpleCommand <object, object>(ExecuteLogoutCommand); }
protected override void Init(out IViewInjectionService service, out IPanelWrapper <Panel> target) { Grid control = new Grid(); var s = new ViewInjectionService(); Interaction.GetBehaviors(control).Add(s); target = new PanelWrapper() { Target = control }; service = s; }
public MainViewViewModel( IViewAwareStatus viewAwareStatus, IMessageBoxService messageBoxService, IViewInjectionService viewInjectionService) { //this.regionManager = regionManager; this.viewAwareStatus = viewAwareStatus; this.messageBoxService = messageBoxService; this.viewInjectionService = viewInjectionService; this.viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded); //Listen for login event Mediator.Instance.Register(this); LogoutCommand = new SimpleCommand<object, object>(ExecuteLogoutCommand); }
protected override void Init(out IViewInjectionService service, out IContentPresenterWrapper <ContentPresenter> target) { ContentPresenter control = new ContentPresenter(); var s = new ViewInjectionService(); Interaction.GetBehaviors(control).Add(s); target = new ContentPresenterWrapper() { Target = control }; service = s; }
protected override void Init(out IViewInjectionService service, out ISelectorWrapper <TabControl> target) { TabControl control = new TabControl(); var s = new ViewInjectionService(); Interaction.GetBehaviors(control).Add(s); target = new TabControlWrapper() { Target = control }; service = s; }
public void Remove(IViewInjectionService service) { if (service == null) { return; } var serviceReference = GetServiceReference(service); if (serviceReference == null) { return; } ServiceReferences.Remove(serviceReference); }
public ViewAllUsersViewViewModel(IMessageBoxService messageBoxService, IViewAwareStatus viewAwareStatus, IViewInjectionService viewInjectionService, IUserService userService, IOpenFileService openFileService) { this.messageBoxService = messageBoxService; this.viewAwareStatus = viewAwareStatus; this.userService = userService; this.viewInjectionService = viewInjectionService; this.openFileService = openFileService; Mediator.Instance.Register(this); //Initialise Commands UpdateUserCommand = new SimpleCommand <object, object>(CanExecuteUpdateUserCommand, ExecuteUpdateUserCommand); UploadUserImageCommand = new SimpleCommand <object, object>(CanExecuteUploadUserImageCommand, ExecuteUploadUserImageCommand); viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded); }
public ViewAllUsersViewViewModel(IMessageBoxService messageBoxService, IViewAwareStatus viewAwareStatus, IViewInjectionService viewInjectionService, IUserService userService, IOpenFileService openFileService) { this.messageBoxService = messageBoxService; this.viewAwareStatus = viewAwareStatus; this.userService = userService; this.viewInjectionService = viewInjectionService; this.openFileService = openFileService; Mediator.Instance.Register(this); //Initialise Commands UpdateUserCommand = new SimpleCommand<object, object>(CanExecuteUpdateUserCommand, ExecuteUpdateUserCommand); UploadUserImageCommand = new SimpleCommand<object, object>(CanExecuteUploadUserImageCommand, ExecuteUploadUserImageCommand); viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded); }
public void Add(IViewInjectionService service) { if (service == null || string.IsNullOrEmpty(service.RegionName)) { return; } if (GetServiceReference(service) != null) { return; } if (FindService(x => x.RegionName == service.RegionName) != null) { throw new InvalidOperationException(Exception1); } ServiceReferences.Add(new WeakReference(service)); }
public void ViewModelKeyTest() { ViewInjectionService service = new ViewInjectionService(); IViewInjectionService iService = service; ContentControl target = new ContentControl(); Interaction.GetBehaviors(target).Add(service); object vm1 = new object(); object vm2 = new object(); Window.Content = target; EnqueueShowWindow(); EnqueueCallback(() => { iService.Inject(null, null); iService.Inject(null, vm1); Assert.AreEqual(1, iService.ViewModels.Count()); Assert.AreSame(vm1, iService.ViewModels.ElementAt(0)); Assert.AreEqual(vm1, iService.GetKey(vm1)); Assert.AreSame(vm1, iService.GetViewModel(vm1)); AssertHelper.AssertThrows <InvalidOperationException>(() => iService.Inject(null, vm1), x => Assert.AreEqual("A view model with the same key already exists in the ViewInjectionService region.", x.Message)); service.RegionName = "Test"; AssertHelper.AssertThrows <InvalidOperationException>(() => iService.Inject(null, vm1), x => Assert.AreEqual("A view model with the same key already exists in the Test region.", x.Message)); iService.Inject("New", vm2); Assert.AreEqual(2, iService.ViewModels.Count()); Assert.AreSame(vm2, iService.ViewModels.ElementAt(1)); Assert.AreEqual("New", iService.GetKey(vm2)); Assert.AreSame(vm2, iService.GetViewModel("New")); iService.Remove(vm1); Assert.AreEqual(1, iService.ViewModels.Count()); iService.Remove(vm2); Assert.AreEqual(0, iService.ViewModels.Count()); }); EnqueueTestComplete(); }
static void VerifyService(IViewInjectionService service) { if(service == null) throw new ArgumentNullException("service"); }
public UserModule(IViewInjectionService viewInjectionService, IMessageBoxService messageBoxService) { this.viewInjectionService = viewInjectionService; this.messageBoxService = messageBoxService; }
public static object GetViewModel(this IViewInjectionService service, object key) { VerifyService(service); return(service.ViewModels.FirstOrDefault(x => object.Equals(service.GetKey(x), key))); }
public LoginViewViewModel(IViewAwareStatus viewAwareStatus, IAuthenticateService authenticateService, IMessageBoxService messageBoxService, IBusinessUnitService businessUnitService, IViewInjectionService viewInjectionService) { //base.IsCloseable = true; //Initialise Services this.viewAwareStatus = viewAwareStatus; this.authenticateService = authenticateService; this.messageBoxService = messageBoxService; this.businessUnitService = businessUnitService; this.viewInjectionService = viewInjectionService; //this.regionManager = regionManager; //Initialise Properties UserName = new DataWrapper<string>(this, userNameArgs); Password = new DataWrapper<string>(this, passwordArgs); SelectedBusinessUnit = new DataWrapper<Int32>(this, businessUnitsArgs); this.viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded); cachedListOfDataWrappers = DataWrapperHelper.GetWrapperProperties<LoginViewViewModel>(this); //Register Mediator Mediator.Instance.Register(this); //Initialise Rules userName.AddRule(UserNameCannnotBeEmptyRule); password.AddRule(PasswordCannotBeEmptyRule); selectedBusinessUnit.AddRule(SelectedBusinessUnitCannotBeEmpty); //Initialise Commands LoginCommand = new SimpleCommand<object, object>(CanExecuteLoginCommand, ExecuteLoginCommand); CancelLoginCommand = new SimpleCommand<object, object>(ExecuteCancelLoginCommand); }
public static void Inject(this IViewInjectionService service, object key, object viewModel, string viewName) { VerifyService(service); service.Inject(key, viewModel, viewName, null); }
WeakReference GetServiceReference(IViewInjectionService service) { UpdateServiceReferences(); return(ServiceReferences.FirstOrDefault(x => x.Target == service)); }
public AuthenticationModule(IViewInjectionService viewInjectionService, IMessageBoxService messageBoxService) { this.viewInjectionService = viewInjectionService; this.messageBoxService = messageBoxService; }
public virtual void RegisterService(IViewInjectionService service) { ServiceManager.Add(service); QueueManager.UpdateQueues(); }
public static void Inject(this IViewInjectionService service, object key, object viewModel, Type viewType) { VerifyService(service); service.Inject(key, viewModel, null, viewType); }