コード例 #1
0
        static RepositoryCloneViewModel CreateTarget(
            IOperatingSystem os = null,
            IConnectionManager connectionManager     = null,
            IRepositoryCloneService service          = null,
            IUsageService usageService               = null,
            IUsageTracker usageTracker               = null,
            IRepositorySelectViewModel gitHubTab     = null,
            IRepositorySelectViewModel enterpriseTab = null,
            IGitService gitService         = null,
            IRepositoryUrlViewModel urlTab = null,
            string defaultClonePath        = defaultPath)
        {
            os = os ?? Substitute.For <IOperatingSystem>();
            connectionManager = connectionManager ?? CreateConnectionManager("https://github.com");
            service           = service ?? CreateRepositoryCloneService(defaultClonePath);
            usageService      = usageService ?? CreateUsageService();
            usageTracker      = usageTracker ?? Substitute.For <IUsageTracker>();
            gitHubTab         = gitHubTab ?? CreateSelectViewModel();
            enterpriseTab     = enterpriseTab ?? CreateSelectViewModel();
            gitService        = gitService ?? CreateGitService(true, "https://github.com/owner/repo");
            urlTab            = urlTab ?? CreateRepositoryUrlViewModel();

            return(new RepositoryCloneViewModel(
                       os,
                       connectionManager,
                       service,
                       gitService,
                       usageService,
                       usageTracker,
                       gitHubTab,
                       enterpriseTab,
                       urlTab));
        }
コード例 #2
0
ファイル: UsageTracker.cs プロジェクト: zotovv/VisualStudio
 public UsageTracker(
     IGitHubServiceProvider gitHubServiceProvider,
     IUsageService service)
 {
     this.gitHubServiceProvider = gitHubServiceProvider;
     this.service = service;
     timer        = StartTimer();
 }
コード例 #3
0
 public UsageTracker(
     IGitHubServiceProvider gitHubServiceProvider,
     IUsageService service,
     IPackageSettings settings)
 {
     this.gitHubServiceProvider = gitHubServiceProvider;
     this.service      = service;
     this.userSettings = settings;
     timer             = StartTimer();
 }
コード例 #4
0
 public UsageTracker(
     IGitHubServiceProvider gitHubServiceProvider,
     IUsageService service,
     IPackageSettings settings,
     JoinableTaskContext joinableTaskContext)
 {
     this.gitHubServiceProvider = gitHubServiceProvider;
     this.service        = service;
     this.userSettings   = settings;
     JoinableTaskContext = joinableTaskContext;
     timer = StartTimer();
 }
コード例 #5
0
        static Tuple <UsageTracker, Func <Task> > CreateTargetAndGetTick(
            IGitHubServiceProvider serviceProvider,
            IUsageService service)
        {
            Func <Task> tick = null;

            service.WhenForAnyArgs(x => x.StartTimer(null, new TimeSpan(), new TimeSpan()))
            .Do(x => tick = x.ArgAt <Func <Task> >(0));

            var target = new UsageTracker(serviceProvider, service);

            return(Tuple.Create(target, tick));
        }
コード例 #6
0
        public RepositoryCloneViewModel(
            IOperatingSystem os,
            IConnectionManager connectionManager,
            IRepositoryCloneService service,
            IGitService gitService,
            IUsageService usageService,
            IUsageTracker usageTracker,
            IRepositorySelectViewModel gitHubTab,
            IRepositorySelectViewModel enterpriseTab,
            IRepositoryUrlViewModel urlTab)
        {
            this.os = os;
            this.connectionManager = connectionManager;
            this.service           = service;
            this.gitService        = gitService;
            this.usageService      = usageService;
            this.usageTracker      = usageTracker;

            GitHubTab     = gitHubTab;
            EnterpriseTab = enterpriseTab;
            UrlTab        = urlTab;
            tabs          = new IRepositoryCloneTabViewModel[] { GitHubTab, EnterpriseTab, UrlTab };

            var repository = this.WhenAnyValue(x => x.SelectedTabIndex)
                             .SelectMany(x => tabs[x].WhenAnyValue(tab => tab.Repository));

            Path = service.DefaultClonePath;
            repository.Subscribe(x => UpdatePath(x));

            pathWarning = Observable.CombineLatest(
                repository,
                this.WhenAnyValue(x => x.Path),
                ValidatePathWarning)
                          .ToProperty(this, x => x.PathWarning);

            var canClone = Observable.CombineLatest(
                repository, this.WhenAnyValue(x => x.Path),
                (repo, path) => repo != null && !service.DestinationFileExists(path) && !service.DestinationDirectoryExists(path));

            var canOpen = Observable.CombineLatest(
                repository, this.WhenAnyValue(x => x.Path),
                (repo, path) => repo != null && !service.DestinationFileExists(path) && service.DestinationDirectoryExists(path));

            Browse = ReactiveCommand.Create().OnExecuteCompleted(_ => BrowseForDirectory());
            Clone  = ReactiveCommand.CreateAsyncObservable(
                canClone,
                _ => repository.Select(x => new CloneDialogResult(Path, x?.CloneUrl)));
            Open = ReactiveCommand.CreateAsyncObservable(
                canOpen,
                _ => repository.Select(x => new CloneDialogResult(Path, x?.CloneUrl)));
        }
コード例 #7
0
ファイル: UsageViewModel.cs プロジェクト: xetle/wpfsample
        public UsageViewModel(IEventAggregator eventAggregator, IUsageService usageService, IMenuService menuService, IRegionManager regionManager)
        {
            this.eventAggregator = eventAggregator;
            this.usageService    = usageService;
            this.menuService     = menuService;
            this.regionManager   = regionManager;

            CounterpartyChangeEvent counterpartyChangeEvent = eventAggregator.GetEvent <CounterpartyChangeEvent>();

            counterpartyChangeEvent.Subscribe(OnCounterpartyChanged);

            showUsageCommand = new DelegateCommand(ShowUsage);

            menuService.RegisterMenu(new MenuEntry()
            {
                Text = viewName, Command = showUsageCommand
            });
        }
コード例 #8
0
        public UsageDailyViewModel(IEventAggregator eventAggregator, IUsageService usageService, IMenuService menuService, IRegionManager regionManager)
        {
            this.eventAggregator = eventAggregator;
            this.usageService    = usageService;
            this.menuService     = menuService;
            this.regionManager   = regionManager;

            CounterpartyChangeEvent evt = eventAggregator.GetEvent <CounterpartyChangeEvent>();

            evt.Subscribe(OnSelectedCounterpartyChanged);

            // We may be launching this view after the counterparty has been selected e.g. popup window so get the usage for the currently selected counterparty
            if (usageService.CurrentCounterparty != null)
            {
                var usages = usageService.FindLatestUsageByCounterparty(usageService.CurrentCounterparty);
                Usages = new ObservableCollection <Model.Usage>(usages);
            }

            showUsageDailyCommand = new DelegateCommand(ShowUsageDaily);

            menuService.RegisterMenu(new MenuEntry()
            {
                Text = "Daily Usage", Command = showUsageDailyCommand
            });

            showGraphCommand = new DelegateCommand(ShowGraph);

            menuService.RegisterMenu(new MenuEntry()
            {
                Text = "Show Graph", Command = showGraphCommand
            });

            showUsageDailyPopupCommand = new DelegateCommand(ShowUsageDailyPopup);
            menuService.RegisterMenu(new MenuEntry()
            {
                Text = "Show PopUp Daily Usage", Command = showUsageDailyPopupCommand
            });
        }
コード例 #9
0
 public UsageController(IUsageService usageService)
 {
     _usageService = usageService;
 }
コード例 #10
0
 public UsageController(IUsageService loggerService)
 {
     _loggerService = loggerService;
 }