@@ -25,16 +25,16 @@ public bool CanAddComponent(CodeExplorerItemViewModel parameter, IEnumerable<Pro
25
25
{
26
26
var project = GetDeclaration ( parameter ) ? . Project ;
27
27
28
- if ( project == null && _vbe . ProjectsCount = = 1 )
28
+ if ( project != null || _vbe . ProjectsCount ! = 1 )
29
29
{
30
- using ( var vbProjects = _vbe . VBProjects )
31
- using ( project = vbProjects [ 1 ] )
32
- {
33
- return project != null && allowableProjectTypes . Contains ( project . Type ) ;
34
- }
30
+ return project != null && allowableProjectTypes . Contains ( project . Type ) ;
35
31
}
36
32
37
- return project != null && allowableProjectTypes . Contains ( project . Type ) ;
33
+ using ( var vbProjects = _vbe . VBProjects )
34
+ using ( project = vbProjects [ 1 ] )
35
+ {
36
+ return project != null && allowableProjectTypes . Contains ( project . Type ) ;
37
+ }
38
38
39
39
}
40
40
catch ( COMException )
@@ -75,8 +75,8 @@ public void AddComponent(CodeExplorerItemViewModel node, string moduleText)
75
75
return ; //The project is not available.
76
76
}
77
77
78
- string optionCompare = string . Empty ;
79
- using ( IHostApplication hostApp = _vbe . HostApplication ( ) )
78
+ string optionCompare ;
79
+ using ( var hostApp = _vbe . HostApplication ( ) )
80
80
{
81
81
optionCompare = hostApp ? . ApplicationName == "Access" ? "Option Compare Database" :
82
82
string . Empty ;
@@ -87,13 +87,12 @@ public void AddComponent(CodeExplorerItemViewModel node, string moduleText)
87
87
: ComponentsCollectionFromActiveProject ( ) )
88
88
{
89
89
var folderAnnotation = $ "'@Folder(\" { GetFolder ( node ) } \" )";
90
- string fileName = createTempTextFile ( moduleText ) ;
90
+ var fileName = CreateTempTextFile ( moduleText ) ;
91
91
92
92
using ( var newComponent = components . Import ( fileName ) )
93
93
{
94
94
using ( var codeModule = newComponent . CodeModule )
95
95
{
96
- var delarationLines = string . Concat ( folderAnnotation , optionCompare ) ;
97
96
if ( optionCompare . Length > 0 )
98
97
{
99
98
codeModule . InsertLines ( 1 , optionCompare ) ;
@@ -109,14 +108,14 @@ public void AddComponent(CodeExplorerItemViewModel node, string moduleText)
109
108
}
110
109
}
111
110
112
- private string createTempTextFile ( string moduleText )
111
+ private static string CreateTempTextFile ( string moduleText )
113
112
{
114
- string tempFolder = ApplicationConstants . RUBBERDUCK_TEMP_PATH ;
113
+ var tempFolder = ApplicationConstants . RUBBERDUCK_TEMP_PATH ;
115
114
if ( ! Directory . Exists ( tempFolder ) )
116
115
{
117
116
Directory . CreateDirectory ( tempFolder ) ;
118
117
}
119
- string filePath = Path . Combine ( tempFolder , Path . GetRandomFileName ( ) ) ;
118
+ var filePath = Path . Combine ( tempFolder , Path . GetRandomFileName ( ) ) ;
120
119
File . WriteAllText ( filePath , moduleText ) ;
121
120
return filePath ;
122
121
}
0 commit comments