Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 static void VerifyService(IViewInjectionService service)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
 }
Exemplo n.º 3
0
        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 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);
        }
Exemplo n.º 7
0
 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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 13
0
        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;
        }
Exemplo n.º 14
0
            public void Remove(IViewInjectionService service)
            {
                if (service == null)
                {
                    return;
                }
                var serviceReference = GetServiceReference(service);

                if (serviceReference == null)
                {
                    return;
                }
                ServiceReferences.Remove(serviceReference);
            }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 17
0
 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));
 }
Exemplo n.º 18
0
        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");
 }
Exemplo n.º 20
0
 public UserModule(IViewInjectionService viewInjectionService, IMessageBoxService messageBoxService)
 {
     this.viewInjectionService = viewInjectionService;
     this.messageBoxService    = messageBoxService;
 }
Exemplo n.º 21
0
 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);
        }
Exemplo n.º 23
0
 public static void Inject(this IViewInjectionService service, object key, object viewModel, string viewName)
 {
     VerifyService(service);
     service.Inject(key, viewModel, viewName, null);
 }
Exemplo n.º 24
0
 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 UserModule(IViewInjectionService viewInjectionService, IMessageBoxService messageBoxService)
 {
     this.viewInjectionService = viewInjectionService;
     this.messageBoxService = messageBoxService;
 }
 public AuthenticationModule(IViewInjectionService viewInjectionService, IMessageBoxService messageBoxService)
 {
     this.viewInjectionService = viewInjectionService;
     this.messageBoxService    = messageBoxService;
 }
Exemplo n.º 28
0
 public virtual void RegisterService(IViewInjectionService service)
 {
     ServiceManager.Add(service);
     QueueManager.UpdateQueues();
 }
Exemplo n.º 29
0
 public static void Inject(this IViewInjectionService service, object key, object viewModel, Type viewType)
 {
     VerifyService(service);
     service.Inject(key, viewModel, null, viewType);
 }