This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +25
-6
lines changed
Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 22using System . ComponentModel . Composition ;
33using GitHub . UI ;
44using GitHub . ViewModels ;
5+ using System . Windows . Controls ;
6+ using System . Linq ;
57
68namespace GitHub . Exports {
79
@@ -42,4 +44,12 @@ public interface IViewModelMetadata
4244 {
4345 UIViewType ViewType { get ; }
4446 }
47+
48+ public static class ExportViewAttributeExtensions
49+ {
50+ public static bool IsViewType ( this UserControl c , UIViewType type )
51+ {
52+ return c . GetType ( ) . GetCustomAttributesData ( ) . Any ( x => x . AttributeType . Equals ( typeof ( ExportViewAttribute ) ) && ( UIViewType ) x . NamedArguments [ 0 ] . TypedValue . Value == type ) ;
53+ }
54+ }
4555}
Original file line number Diff line number Diff line change 22using System . ComponentModel . Composition . Hosting ;
33using GitHub . Models ;
44using GitHub . UI ;
5+ using System . Windows . Controls ;
56
67namespace GitHub . Services
78{
@@ -20,7 +21,7 @@ public interface IUIProvider
2021 void AddService ( Type t , object instance ) ;
2122 void RemoveService ( Type t ) ;
2223
23- IObservable < object > SetupUI ( UIControllerFlow controllerFlow , IConnection connection ) ;
24+ IObservable < UserControl > SetupUI ( UIControllerFlow controllerFlow , IConnection connection ) ;
2425 void RunUI ( ) ;
2526 void RunUI ( UIControllerFlow controllerFlow , IConnection connection ) ;
2627 }
Original file line number Diff line number Diff line change 1717using NLog ;
1818using System . Reactive . Linq ;
1919using GitHub . Infrastructure ;
20+ using System . Windows . Controls ;
2021
2122namespace GitHub . VisualStudio
2223{
@@ -184,12 +185,12 @@ public void RemoveService(Type t)
184185 }
185186
186187 UI . WindowController windowController ;
187- public IObservable < object > SetupUI ( UIControllerFlow controllerFlow , [ AllowNull ] IConnection connection )
188+ public IObservable < UserControl > SetupUI ( UIControllerFlow controllerFlow , [ AllowNull ] IConnection connection )
188189 {
189190 if ( ! Initialized )
190191 {
191192 log . Error ( "ExportProvider is not initialized, cannot setup UI." ) ;
192- return Observable . Return < object > ( null ) ;
193+ return Observable . Return < UserControl > ( null ) ;
193194 }
194195
195196 StopUI ( ) ;
Original file line number Diff line number Diff line change 1616using System . Windows . Data ;
1717using System . ComponentModel ;
1818using ReactiveUI ;
19+ using GitHub . Exports ;
1920
2021namespace GitHub . VisualStudio . TeamExplorer . Connect
2122{
@@ -227,13 +228,11 @@ void RefreshRepositories()
227228
228229 public void DoCreate ( )
229230 {
230- isCreating = true ;
231231 StartFlow ( UIControllerFlow . Create ) ;
232232 }
233233
234234 public void DoClone ( )
235235 {
236- isCloning = true ;
237236 StartFlow ( UIControllerFlow . Clone ) ;
238237 }
239238
@@ -272,7 +271,15 @@ void StartFlow(UIControllerFlow controllerFlow)
272271 {
273272 var uiProvider = ServiceProvider . GetExportedValue < IUIProvider > ( ) ;
274273 uiProvider . GitServiceProvider = ServiceProvider ;
275- uiProvider . RunUI ( controllerFlow , SectionConnection ) ;
274+ var ret = uiProvider . SetupUI ( controllerFlow , SectionConnection ) ;
275+ ret . Subscribe ( ( c ) =>
276+ {
277+ if ( c . IsViewType ( UIViewType . Clone ) )
278+ isCloning = true ;
279+ else if ( c . IsViewType ( UIViewType . Create ) )
280+ isCreating = true ;
281+ } ) ;
282+ uiProvider . RunUI ( ) ;
276283 }
277284
278285 bool disposed ;
You can’t perform that action at this time.
0 commit comments