Exemple #1
0
        public TeamMembersWidget()
        {
            Title = "Team Members";

            controller = NewController<TeamMembersController>();
            viewModel = GetInstance<TeamMembersViewModel>();
            settingsViewModel = GetInstance<TeamMembersSettingsViewModel>();

            PropertyChanged += TeamMembersWidget_PropertyChanged;

            View = new TeamMembersView { DataContext = viewModel };
            SettingsView = new TeamMembersSettingsView { DataContext = settingsViewModel };

            settingsViewModel.PropertyChanged += ViewModelPropertyChanged;
            
        }
        public TeamMembersController(
            TeamMembersViewModel teamMembersViewModel,
            TeamMembersSettingsViewModel teamMembersSettingsViewModel,
            IRepository<Userdb> userdbRepository,
            IRepository<Configuration> configRepo,
            IPersistDomainModelsAsync<Configuration> configPersister,
            IInvokeBackgroundWorker<IEnumerable<ProjectInfoServer>> asyncClient, 
            ILog logger,
            ITimer timer,
            IUIInvoker uiInvoker,
            IProgressbar loadingNotifier, IMetadataService metadataService)
            
        {
            Guard.Requires<ArgumentException>(userdbRepository != null, "userdbRepository");
            Guard.Requires<ArgumentException>(configRepo != null, "configRepository");
            Guard.Requires<ArgumentException>(configPersister != null, "configPersisterRepository");
            Guard.Requires<ArgumentException>(asyncClient != null, "asyncClient");
            Guard.Requires<ArgumentException>(logger != null, "logger");

            this.teamMembersViewModel = teamMembersViewModel;
            this.teamMembersSettingsViewModel = teamMembersSettingsViewModel;
            this.userdbRepository = userdbRepository;
            this.metadataService = metadataService;
            this.configRepository = configRepo;
            this.configPersisterRepository = configPersister;
            this.asyncClient = asyncClient;
            this.logger = logger;
            this.timer = timer;
            this.uiInvoker = uiInvoker;
            this.loadingNotifier = loadingNotifier;

            timer.Start(REFRESH_INTERVAL);
            timer.Elapsed += OnNotifiedToRefresh;
            teamMembersSettingsViewModel.Save.AfterExecute += (s, e) => OnSave();
            teamMembersSettingsViewModel.Refresh.AfterExecute += (s, e) => OnRefresh();
            teamMembersSettingsViewModel.PropertyChanged += PropertyChanged;
            configPersister.SaveCompleted += ConfigPersisterSaveCompleted;

            
            LoadConfig();
            LoadData();
        }
        private static void CreateController()
        {
            viewModel = new TeamMembersViewModel();
            settingsViewModel = new TeamMembersSettingsViewModel();

            controller = new TeamMembersController(
                viewModel,
                settingsViewModel,
                mockRepository.Object,
                configRepositoryMock.Object,
                mockPersistConfiguration.Object,
                BackgroundWorkerInvoker,
                mockLog.Object,
                mockRefershTimer.Object,
                new NoUIInvokation(),
                loadingNotifierMock.Object,
                metadataServiceMock.Object);
        }