1111namespace GitHub . VisualStudio . Commands
1212{
1313 /// <summary>
14- /// Creates a gist from the currently selected text.
14+ /// Creates a GitHub Gist from the currently selected text.
1515 /// </summary>
1616 [ Export ( typeof ( ICreateGistCommand ) ) ]
17- public class CreateGistCommand : VsCommand , ICreateGistCommand
17+ public class CreateGistCommand : CreateGistCommandBase
1818 {
1919 readonly Lazy < IDialogService > dialogService ;
2020 readonly Lazy < ISelectedTextProvider > selectedTextProvider ;
@@ -25,11 +25,8 @@ protected CreateGistCommand(
2525 Lazy < IDialogService > dialogService ,
2626 Lazy < ISelectedTextProvider > selectedTextProvider ,
2727 Lazy < IConnectionManager > connectionManager )
28- : base ( CommandSet , CommandId )
28+ : base ( CommandSet , CommandId , dialogService , selectedTextProvider , connectionManager , true )
2929 {
30- this . dialogService = dialogService ;
31- this . selectedTextProvider = selectedTextProvider ;
32- this . connectionManager = connectionManager ;
3330 }
3431
3532 /// <summary>
@@ -41,6 +38,32 @@ protected CreateGistCommand(
4138 /// Gets the numeric identifier of the command.
4239 /// </summary>
4340 public const int CommandId = PkgCmdIDList . createGistCommand ;
41+ }
42+
43+ /// <summary>
44+ /// Creates a GitHub or GitHub Enterprise Gist from the currently selected text.
45+ /// </summary>
46+ [ Export ( typeof ( ICreateGistCommand ) ) ]
47+ public abstract class CreateGistCommandBase : VsCommand , ICreateGistCommand
48+ {
49+ readonly bool isGitHubDotCom ;
50+ readonly Lazy < IDialogService > dialogService ;
51+ readonly Lazy < ISelectedTextProvider > selectedTextProvider ;
52+ readonly Lazy < IConnectionManager > connectionManager ;
53+
54+ protected CreateGistCommandBase (
55+ Guid commandSet , int commandId ,
56+ Lazy < IDialogService > dialogService ,
57+ Lazy < ISelectedTextProvider > selectedTextProvider ,
58+ Lazy < IConnectionManager > connectionManager ,
59+ bool isGitHubDotCom )
60+ : base ( commandSet , commandId )
61+ {
62+ this . isGitHubDotCom = isGitHubDotCom ;
63+ this . dialogService = dialogService ;
64+ this . selectedTextProvider = selectedTextProvider ;
65+ this . connectionManager = connectionManager ;
66+ }
4467
4568 ISelectedTextProvider SelectedTextProvider => selectedTextProvider . Value ;
4669
@@ -68,7 +91,7 @@ bool HasConnection()
6891 async Task < IConnection > FindConnectionAsync ( )
6992 {
7093 var connections = await connectionManager . Value . GetLoadedConnections ( ) ;
71- return connections . FirstOrDefault ( x => x . IsLoggedIn && x . HostAddress . IsGitHubDotCom ( ) ) ;
94+ return connections . FirstOrDefault ( x => x . IsLoggedIn && x . HostAddress . IsGitHubDotCom ( ) == isGitHubDotCom ) ;
7295 }
7396 }
7497}
0 commit comments