@@ -21,7 +21,7 @@ namespace GitHub.VisualStudio.Base
21
21
public class TeamExplorerServiceHolder : ITeamExplorerServiceHolder
22
22
{
23
23
static readonly ILogger log = LogManager . ForContext < TeamExplorerServiceHolder > ( ) ;
24
- readonly IVSUIContextFactory uiContextFactory ;
24
+ readonly IVSUIContextFactory uiContextFactory = null ;
25
25
readonly Dictionary < object , Action < ILocalRepositoryModel > > activeRepoHandlers = new Dictionary < object , Action < ILocalRepositoryModel > > ( ) ;
26
26
ILocalRepositoryModel activeRepo ;
27
27
bool activeRepoNotified = false ;
@@ -33,9 +33,12 @@ public class TeamExplorerServiceHolder : ITeamExplorerServiceHolder
33
33
// ActiveRepositories PropertyChanged event comes in on a non-main thread
34
34
readonly SynchronizationContext syncContext ;
35
35
36
- public TeamExplorerServiceHolder ( IVSUIContextFactory uiContextFactory , IVSGitExt gitService )
36
+ [ ImportingConstructor ]
37
+ //public TeamExplorerServiceHolder(IVSUIContextFactory uiContextFactory, IVSGitExt gitService)
38
+ public TeamExplorerServiceHolder ( IVSGitExt gitService )
37
39
{
38
- this . uiContextFactory = uiContextFactory ;
40
+ Debugger . Break ( ) ;
41
+ //this.uiContextFactory = uiContextFactory;
39
42
this . GitService = gitService ;
40
43
syncContext = SynchronizationContext . Current ;
41
44
}
@@ -80,7 +83,7 @@ public void Subscribe(object who, Action<ILocalRepositoryModel> handler)
80
83
81
84
bool notificationsExist ;
82
85
ILocalRepositoryModel repo ;
83
- lock ( activeRepoHandlers )
86
+ lock ( activeRepoHandlers )
84
87
{
85
88
repo = ActiveRepo ;
86
89
notificationsExist = activeRepoNotified ;
@@ -142,7 +145,7 @@ void NotifyActiveRepo()
142
145
}
143
146
}
144
147
145
- void UIContextChanged ( object sender , UIContextChangedEventArgs e )
148
+ void UIContextChanged ( object sender , IVSUIContextChangedEventArgs e )
146
149
{
147
150
Guard . ArgumentNotNull ( e , nameof ( e ) ) ;
148
151
@@ -247,6 +250,68 @@ IVSGitExt GitService
247
250
}
248
251
}
249
252
253
+ [ Export ( typeof ( IVSUIContextFactory ) ) ]
254
+ [ PartCreationPolicy ( CreationPolicy . Shared ) ]
255
+ public class VSUIContextFactory : IVSUIContextFactory
256
+ {
257
+ [ ImportingConstructor ]
258
+ public VSUIContextFactory ( )
259
+ {
260
+ Debugger . Break ( ) ;
261
+ }
262
+
263
+ public IVSUIContext GetUIContext ( Guid contextGuid )
264
+ {
265
+ return new VSUIContext ( UIContext . FromUIContextGuid ( contextGuid ) ) ;
266
+ }
267
+ }
268
+
269
+ public class VSUIContextChangedEventArgs : IVSUIContextChangedEventArgs
270
+ {
271
+ public bool Activated { get ; }
272
+
273
+ public VSUIContextChangedEventArgs ( bool activated )
274
+ {
275
+ Activated = activated ;
276
+ }
277
+ }
278
+
279
+ public class VSUIContext : IVSUIContext
280
+ {
281
+ readonly UIContext context ;
282
+ readonly Dictionary < EventHandler < IVSUIContextChangedEventArgs > , EventHandler < UIContextChangedEventArgs > > handlers =
283
+ new Dictionary < EventHandler < IVSUIContextChangedEventArgs > , EventHandler < UIContextChangedEventArgs > > ( ) ;
284
+ public VSUIContext ( UIContext context )
285
+ {
286
+ this . context = context ;
287
+ }
288
+
289
+ public bool IsActive { get { return context . IsActive ; } }
290
+
291
+ public event EventHandler < IVSUIContextChangedEventArgs > UIContextChanged
292
+ {
293
+ add
294
+ {
295
+ EventHandler < UIContextChangedEventArgs > handler = null ;
296
+ if ( ! handlers . TryGetValue ( value , out handler ) )
297
+ {
298
+ handler = ( s , e ) => value . Invoke ( s , new VSUIContextChangedEventArgs ( e . Activated ) ) ;
299
+ handlers . Add ( value , handler ) ;
300
+ }
301
+ context . UIContextChanged += handler ;
302
+ }
303
+ remove
304
+ {
305
+ EventHandler < UIContextChangedEventArgs > handler = null ;
306
+ if ( handlers . TryGetValue ( value , out handler ) )
307
+ {
308
+ handlers . Remove ( value ) ;
309
+ context . UIContextChanged -= handler ;
310
+ }
311
+ }
312
+ }
313
+ }
314
+
250
315
static class IGitRepositoryInfoExtensions
251
316
{
252
317
/// <summary>
0 commit comments