7
7
using Microsoft . VisualStudio . Shell ;
8
8
using Project = EnvDTE . Project ;
9
9
10
- namespace CodingWithCalvin . OpenBinFolder . Vsix . Commands
10
+ namespace CodingWithCalvin . OpenBinFolder . Commands
11
11
{
12
12
internal class OpenBinFolderCommand
13
13
{
@@ -17,18 +17,22 @@ private OpenBinFolderCommand(Package package)
17
17
{
18
18
_package = package ;
19
19
20
- var commandService = ( OleMenuCommandService ) ServiceProvider . GetService ( typeof ( IMenuCommandService ) ) ;
20
+ var commandService = ( OleMenuCommandService )
21
+ ServiceProvider . GetService ( typeof ( IMenuCommandService ) ) ;
21
22
22
23
if ( commandService == null )
23
24
{
24
25
return ;
25
26
}
26
27
27
- var menuCommandId = new CommandID ( PackageGuids . CommandSetGuid , PackageIds . OpenBinCommandId ) ;
28
+ var menuCommandId = new CommandID (
29
+ PackageGuids . CommandSetGuid ,
30
+ PackageIds . OpenBinCommandId
31
+ ) ;
28
32
var menuItem = new MenuCommand ( OpenPath , menuCommandId ) ;
29
33
commandService . AddCommand ( menuItem ) ;
30
34
}
31
-
35
+
32
36
private IServiceProvider ServiceProvider => _package ;
33
37
34
38
public static void Initialize ( Package package )
@@ -39,13 +43,16 @@ public static void Initialize(Package package)
39
43
private void OpenPath ( object sender , EventArgs e )
40
44
{
41
45
ThreadHelper . ThrowIfNotOnUIThread ( ) ;
42
-
46
+
43
47
if ( ! ( ServiceProvider . GetService ( typeof ( DTE ) ) is DTE2 dte ) )
44
48
{
45
49
throw new ArgumentNullException ( nameof ( dte ) ) ;
46
50
}
47
51
48
- foreach ( UIHierarchyItem selectedItem in ( Array ) dte . ToolWindows . SolutionExplorer . SelectedItems )
52
+ foreach (
53
+ UIHierarchyItem selectedItem in ( Array )
54
+ dte . ToolWindows . SolutionExplorer . SelectedItems
55
+ )
49
56
{
50
57
switch ( selectedItem . Object )
51
58
{
@@ -56,11 +63,13 @@ private void OpenPath(object sender, EventArgs e)
56
63
}
57
64
catch ( Exception ex )
58
65
{
59
- MessageBox . Show ( $@ "
66
+ MessageBox . Show (
67
+ $@ "
60
68
Unable to determine output path for selected project
61
69
{ Environment . NewLine }
62
70
{ Environment . NewLine }
63
- Exception: { ex . Message } " ) ;
71
+ Exception: { ex . Message } "
72
+ ) ;
64
73
}
65
74
66
75
break ;
@@ -69,18 +78,18 @@ private void OpenPath(object sender, EventArgs e)
69
78
70
79
void OpenProjectBinFolder ( Project project )
71
80
{
72
- var projectPath = Path . GetDirectoryName ( project . FullName )
73
- ?? throw new InvalidOperationException ( ) ;
81
+ var projectPath =
82
+ Path . GetDirectoryName ( project . FullName )
83
+ ?? throw new InvalidOperationException ( ) ;
74
84
75
- var projectOutputPath = project . ConfigurationManager . ActiveConfiguration . Properties
76
- . Item ( "OutputPath" ) . Value . ToString ( ) ;
85
+ var projectOutputPath = project
86
+ . ConfigurationManager . ActiveConfiguration . Properties . Item ( "OutputPath" )
87
+ . Value . ToString ( ) ;
77
88
78
89
var projectBinPath = Path . Combine ( projectPath , projectOutputPath ) ;
79
90
80
91
System . Diagnostics . Process . Start (
81
- Directory . Exists ( projectBinPath )
82
- ? projectBinPath
83
- : projectPath
92
+ Directory . Exists ( projectBinPath ) ? projectBinPath : projectPath
84
93
) ;
85
94
}
86
95
}
0 commit comments