|
5 | 5 | using System.Windows.Controls.Primitives; |
6 | 6 | using System.ComponentModel.Composition; |
7 | 7 | using System.Reactive.Linq; |
8 | | -using System.Linq.Expressions; |
9 | 8 | using GitHub.Commands; |
10 | 9 | using GitHub.InlineReviews.Views; |
11 | 10 | using GitHub.InlineReviews.ViewModels; |
12 | 11 | using GitHub.Services; |
13 | 12 | using GitHub.Models; |
14 | 13 | using GitHub.Logging; |
15 | | -using GitHub.Extensions; |
16 | 14 | using Serilog; |
17 | 15 | using ReactiveUI; |
18 | 16 |
|
@@ -45,10 +43,10 @@ public PullRequestStatusBarManager( |
45 | 43 | Lazy<IPullRequestSessionManager> pullRequestSessionManager, |
46 | 44 | Lazy<ITeamExplorerContext> teamExplorerContext) |
47 | 45 | { |
48 | | - this.openPullRequestsCommand = new UsageTrackingCommand(openPullRequestsCommand, |
49 | | - usageTracker, x => x.NumberOfStatusBarOpenPullRequestList); |
50 | | - this.showCurrentPullRequestCommand = new UsageTrackingCommand(showCurrentPullRequestCommand, |
51 | | - usageTracker, x => x.NumberOfShowCurrentPullRequest); |
| 46 | + this.openPullRequestsCommand = new UsageTrackingCommand(usageTracker, |
| 47 | + x => x.NumberOfStatusBarOpenPullRequestList, openPullRequestsCommand); |
| 48 | + this.showCurrentPullRequestCommand = new UsageTrackingCommand(usageTracker, |
| 49 | + x => x.NumberOfShowCurrentPullRequest, showCurrentPullRequestCommand); |
52 | 50 |
|
53 | 51 | this.pullRequestSessionManager = pullRequestSessionManager; |
54 | 52 | this.teamExplorerContext = teamExplorerContext; |
@@ -143,37 +141,5 @@ StatusBar FindSccStatusBar(Window mainWindow) |
143 | 141 | var contentControl = mainWindow?.Template?.FindName(StatusBarPartName, mainWindow) as ContentControl; |
144 | 142 | return contentControl?.Content as StatusBar; |
145 | 143 | } |
146 | | - |
147 | | - class UsageTrackingCommand : ICommand |
148 | | - { |
149 | | - readonly ICommand command; |
150 | | - readonly Lazy<IUsageTracker> usageTracker; |
151 | | - readonly Expression<Func<UsageModel.MeasuresModel, int>> counter; |
152 | | - |
153 | | - internal UsageTrackingCommand(ICommand command, Lazy<IUsageTracker> usageTracker, |
154 | | - Expression<Func<UsageModel.MeasuresModel, int>> counter) |
155 | | - { |
156 | | - this.command = command; |
157 | | - this.usageTracker = usageTracker; |
158 | | - this.counter = counter; |
159 | | - } |
160 | | - |
161 | | - public event EventHandler CanExecuteChanged |
162 | | - { |
163 | | - add { command.CanExecuteChanged += value; } |
164 | | - remove { command.CanExecuteChanged -= value; } |
165 | | - } |
166 | | - |
167 | | - public bool CanExecute(object parameter) |
168 | | - { |
169 | | - return command.CanExecute(parameter); |
170 | | - } |
171 | | - |
172 | | - public void Execute(object parameter) |
173 | | - { |
174 | | - command.Execute(parameter); |
175 | | - usageTracker.Value.IncrementCounter(counter).Forget(); |
176 | | - } |
177 | | - } |
178 | 144 | } |
179 | 145 | } |
0 commit comments