22
33//
44// LifeUtils - LifeUtils - FileUtils.cs
5- // 13 .11.2018 12 :12
5+ // 19 .11.2018 06 :12
66
77#endregion
88
@@ -53,23 +53,23 @@ public static string GetJavaHome()
5353 {
5454 try
5555 {
56- string javaHome = Environment . GetEnvironmentVariable ( "JAVA_HOME" ) ;
56+ var javaHome = Environment . GetEnvironmentVariable ( "JAVA_HOME" ) ;
5757 if ( ! string . IsNullOrEmpty ( javaHome ) && ! string . IsNullOrWhiteSpace ( javaHome ) )
5858 return javaHome ;
5959
60- string jreHome = Environment . GetEnvironmentVariable ( "JRE_HOME" ) ;
60+ var jreHome = Environment . GetEnvironmentVariable ( "JRE_HOME" ) ;
6161 if ( ! string . IsNullOrEmpty ( jreHome ) && ! string . IsNullOrWhiteSpace ( jreHome ) )
6262 return jreHome ;
6363
64- string jdkHome = Environment . GetEnvironmentVariable ( "JDK_HOME" ) ;
64+ var jdkHome = Environment . GetEnvironmentVariable ( "JDK_HOME" ) ;
6565 if ( ! string . IsNullOrEmpty ( jdkHome ) && ! string . IsNullOrWhiteSpace ( jdkHome ) )
6666 return jdkHome ;
6767
68- string registryPath = GetJavaHomeFromRegistry ( ) ? . Trim ( ) ;
68+ var registryPath = GetJavaHomeFromRegistry ( ) ? . Trim ( ) ;
6969 if ( ! string . IsNullOrEmpty ( registryPath ) && ! string . IsNullOrWhiteSpace ( registryPath ) )
7070 return registryPath ;
7171
72- string processPath = GetJavaHomeFromConsole ( ) ;
72+ var processPath = GetJavaHomeFromConsole ( ) ;
7373
7474 return ! string . IsNullOrEmpty ( processPath ) && ! string . IsNullOrWhiteSpace ( processPath )
7575 ? processPath
@@ -88,7 +88,7 @@ public static string GetJavaHome()
8888 /// <returns>The java home from console.</returns>
8989 public static string GetJavaHomeFromConsole ( )
9090 {
91- Process process = new Process
91+ var process = new Process
9292 {
9393 StartInfo = new ProcessStartInfo
9494 {
@@ -104,7 +104,7 @@ public static string GetJavaHomeFromConsole()
104104
105105 process . Start ( ) ;
106106
107- string javaHome = process . StandardOutput . ReadToEnd ( ) ;
107+ var javaHome = process . StandardOutput . ReadToEnd ( ) ;
108108
109109 try
110110 {
@@ -129,10 +129,10 @@ public static string GetJavaHomeFromRegistry()
129129
130130 try
131131 {
132- using ( RegistryKey rk = Registry . LocalMachine . OpenSubKey ( javaKey ) )
132+ using ( var rk = Registry . LocalMachine . OpenSubKey ( javaKey ) )
133133 {
134- string currentVersion = rk ? . GetValue ( "CurrentVersion" ) . ToString ( ) ;
135- using ( RegistryKey key = rk ? . OpenSubKey ( currentVersion ) )
134+ var currentVersion = rk ? . GetValue ( "CurrentVersion" ) . ToString ( ) ;
135+ using ( var key = rk ? . OpenSubKey ( currentVersion ) )
136136 {
137137 return key ? . GetValue ( "JavaHome" ) . ToString ( ) ;
138138 }
@@ -142,10 +142,10 @@ public static string GetJavaHomeFromRegistry()
142142 {
143143 try
144144 {
145- using ( RegistryKey rk = Registry . CurrentUser . OpenSubKey ( javaKey ) )
145+ using ( var rk = Registry . CurrentUser . OpenSubKey ( javaKey ) )
146146 {
147- string currentVersion = rk ? . GetValue ( "CurrentVersion" ) . ToString ( ) ;
148- using ( RegistryKey key = rk ? . OpenSubKey ( currentVersion ) )
147+ var currentVersion = rk ? . GetValue ( "CurrentVersion" ) . ToString ( ) ;
148+ using ( var key = rk ? . OpenSubKey ( currentVersion ) )
149149 {
150150 return key ? . GetValue ( "JavaHome" ) . ToString ( ) ;
151151 }
@@ -165,7 +165,7 @@ public static string GetJavaHomeFromRegistry()
165165 /// <param name="path">The directories path to delete it.</param>
166166 public static void DeleteDirectory ( string path )
167167 {
168- foreach ( string directory in Directory . GetDirectories ( path ) ) DeleteDirectory ( directory ) ;
168+ foreach ( var directory in Directory . GetDirectories ( path ) ) DeleteDirectory ( directory ) ;
169169 try
170170 {
171171 Directory . Delete ( path , true ) ;
0 commit comments