Skip to content

Commit

Permalink
Apply var style
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustafa ÖNCEL committed Nov 19, 2018
1 parent 814356c commit 68c5daa
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/Annotations/Annotations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - Annotations.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
10 changes: 5 additions & 5 deletions LifeUtils/LifeUtils/Annotations/Configurable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - Configurable.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down Expand Up @@ -70,8 +70,8 @@ public static void Init(Type type, IConfigFile config, string section = "Options
PropertyInfo[] propertyInfos =
type.GetProperties(flags);

foreach (FieldInfo fieldInfo in fieldInfos)
foreach (ConfigurableAttribute attr in fieldInfo.GetCustomAttributes<ConfigurableAttribute>(true))
foreach (var fieldInfo in fieldInfos)
foreach (var attr in fieldInfo.GetCustomAttributes<ConfigurableAttribute>(true))
{
if (attr.Key.Equals("")) attr.Key = fieldInfo.Name;
if (!config.ContainsKey(attr.Key, section))
Expand All @@ -82,8 +82,8 @@ public static void Init(Type type, IConfigFile config, string section = "Options
break;
}

foreach (PropertyInfo propertyInfo in propertyInfos)
foreach (ConfigurableAttribute attr in propertyInfo.GetCustomAttributes<ConfigurableAttribute>(true))
foreach (var propertyInfo in propertyInfos)
foreach (var attr in propertyInfo.GetCustomAttributes<ConfigurableAttribute>(true))
{
if (attr.Key.Equals("")) attr.Key = propertyInfo.Name;
if (!config.ContainsKey(attr.Key, section))
Expand Down
10 changes: 5 additions & 5 deletions LifeUtils/LifeUtils/Annotations/Localizable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - Localizable.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down Expand Up @@ -72,8 +72,8 @@ public static void Init(Type type, IConfigFile config)
PropertyInfo[] propertyInfos =
type.GetProperties(flags);

foreach (FieldInfo fieldInfo in fieldInfos)
foreach (LocalizableAttribute attr in fieldInfo.GetCustomAttributes<LocalizableAttribute>(true))
foreach (var fieldInfo in fieldInfos)
foreach (var attr in fieldInfo.GetCustomAttributes<LocalizableAttribute>(true))
{
if (attr.Key.Equals("")) attr.Key = fieldInfo.Name;
if (!config.ContainsKey(attr.Key, section))
Expand All @@ -84,8 +84,8 @@ public static void Init(Type type, IConfigFile config)
break;
}

foreach (PropertyInfo propertyInfo in propertyInfos)
foreach (LocalizableAttribute attr in propertyInfo.GetCustomAttributes<LocalizableAttribute>(true))
foreach (var propertyInfo in propertyInfos)
foreach (var attr in propertyInfo.GetCustomAttributes<LocalizableAttribute>(true))
{
if (attr.Key.Equals("")) attr.Key = propertyInfo.Name;
if (!config.ContainsKey(attr.Key, section))
Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/EnumUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - EnumUtils.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
30 changes: 15 additions & 15 deletions LifeUtils/LifeUtils/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - FileUtils.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down Expand Up @@ -53,23 +53,23 @@ public static string GetJavaHome()
{
try
{
string javaHome = Environment.GetEnvironmentVariable("JAVA_HOME");
var javaHome = Environment.GetEnvironmentVariable("JAVA_HOME");
if (!string.IsNullOrEmpty(javaHome) && !string.IsNullOrWhiteSpace(javaHome))
return javaHome;

string jreHome = Environment.GetEnvironmentVariable("JRE_HOME");
var jreHome = Environment.GetEnvironmentVariable("JRE_HOME");
if (!string.IsNullOrEmpty(jreHome) && !string.IsNullOrWhiteSpace(jreHome))
return jreHome;

string jdkHome = Environment.GetEnvironmentVariable("JDK_HOME");
var jdkHome = Environment.GetEnvironmentVariable("JDK_HOME");
if (!string.IsNullOrEmpty(jdkHome) && !string.IsNullOrWhiteSpace(jdkHome))
return jdkHome;

string registryPath = GetJavaHomeFromRegistry()?.Trim();
var registryPath = GetJavaHomeFromRegistry()?.Trim();
if (!string.IsNullOrEmpty(registryPath) && !string.IsNullOrWhiteSpace(registryPath))
return registryPath;

string processPath = GetJavaHomeFromConsole();
var processPath = GetJavaHomeFromConsole();

return !string.IsNullOrEmpty(processPath) && !string.IsNullOrWhiteSpace(processPath)
? processPath
Expand All @@ -88,7 +88,7 @@ public static string GetJavaHome()
/// <returns>The java home from console.</returns>
public static string GetJavaHomeFromConsole()
{
Process process = new Process
var process = new Process
{
StartInfo = new ProcessStartInfo
{
Expand All @@ -104,7 +104,7 @@ public static string GetJavaHomeFromConsole()

process.Start();

string javaHome = process.StandardOutput.ReadToEnd();
var javaHome = process.StandardOutput.ReadToEnd();

try
{
Expand All @@ -129,10 +129,10 @@ public static string GetJavaHomeFromRegistry()

try
{
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(javaKey))
using (var rk = Registry.LocalMachine.OpenSubKey(javaKey))
{
string currentVersion = rk?.GetValue("CurrentVersion").ToString();
using (RegistryKey key = rk?.OpenSubKey(currentVersion))
var currentVersion = rk?.GetValue("CurrentVersion").ToString();
using (var key = rk?.OpenSubKey(currentVersion))
{
return key?.GetValue("JavaHome").ToString();
}
Expand All @@ -142,10 +142,10 @@ public static string GetJavaHomeFromRegistry()
{
try
{
using (RegistryKey rk = Registry.CurrentUser.OpenSubKey(javaKey))
using (var rk = Registry.CurrentUser.OpenSubKey(javaKey))
{
string currentVersion = rk?.GetValue("CurrentVersion").ToString();
using (RegistryKey key = rk?.OpenSubKey(currentVersion))
var currentVersion = rk?.GetValue("CurrentVersion").ToString();
using (var key = rk?.OpenSubKey(currentVersion))
{
return key?.GetValue("JavaHome").ToString();
}
Expand All @@ -165,7 +165,7 @@ public static string GetJavaHomeFromRegistry()
/// <param name="path">The directories path to delete it.</param>
public static void DeleteDirectory(string path)
{
foreach (string directory in Directory.GetDirectories(path)) DeleteDirectory(directory);
foreach (var directory in Directory.GetDirectories(path)) DeleteDirectory(directory);
try
{
Directory.Delete(path, true);
Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/ICloseable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - ICloseable.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/IConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - IConfigFile.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/IConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - IConverter.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/IFlushable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - IFlushable.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/ITask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - ITask.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
6 changes: 3 additions & 3 deletions LifeUtils/LifeUtils/IniHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - IniHandler.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down Expand Up @@ -42,7 +42,7 @@ public struct IniHandler : IConfigFile
/// <returns>The value of the key.</returns>
public string Read(string key, string section)
{
StringBuilder retVal = new StringBuilder(4096);
var retVal = new StringBuilder(4096);
SafeNativeMethods.GetPrivateProfileString(section, key, "", retVal, 4096, _path);
return retVal.ToString();
}
Expand Down Expand Up @@ -74,7 +74,7 @@ public void Write(string key, string value, string section) =>
/// <returns>True if the ini file contains specified key in the specified section.</returns>
public bool ContainsKey(string key, string section)
{
string value = Read(key, section);
var value = Read(key, section);
return !string.IsNullOrEmpty(value);
}

Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/Kleenean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - Kleenean.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/Minecraft/MinecraftVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - MinecraftVersion.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - AssemblyInfo.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/SafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - SafeNativeMethods.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down
16 changes: 8 additions & 8 deletions LifeUtils/LifeUtils/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - Version.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down Expand Up @@ -50,7 +50,7 @@ public Version(params int[] version)
throw new ArgumentOutOfRangeException(nameof(version),
"Versions must have a minimum of 2 and a maximum of 3 numbers (" + version.Length +
" numbers given)");
for (int i = 0; i < version.Length; i++) _version[i] = version[i];
for (var i = 0; i < version.Length; i++) _version[i] = version[i];
_suffix = null;
}

Expand All @@ -72,18 +72,18 @@ public Version(int major, int minor, int revision, string suffix) :
public Version(string version)
{
if (version == null) throw new ArgumentNullException(nameof(version));
Match match = VersionRegex.Match(version.Trim());
var match = VersionRegex.Match(version.Trim());
if (match.Length < 1)
throw new ArgumentOutOfRangeException("'" + version + "' is not a valid version string");
for (int i = 0; i < _version.Length; i++)
for (var i = 0; i < _version.Length; i++)
if (match.Groups.Count > i + 1)
{
string v = match.Groups[i + 1].Value;
var v = match.Groups[i + 1].Value;
if (!string.IsNullOrEmpty(v))
_version[i] = int.Parse(v);
}

string sfx =
var sfx =
match.Groups[match.Groups.Count].ToString();
_suffix = string.IsNullOrEmpty(sfx) ? null : sfx;
}
Expand All @@ -98,7 +98,7 @@ public int CompareTo(Version other)
{
if (other is null)
return 1;
for (int i = 0; i < _version.Length; i++)
for (var i = 0; i < _version.Length; i++)
{
if (_version[i] > other._version[i])
return 1;
Expand Down Expand Up @@ -191,7 +191,7 @@ public override string ToString() => GetMajor() + "." + GetMinor() + "." + GetRe
/// <returns>The hash code of this version.</returns>
public override int GetHashCode()
{
int hashCode = 1359330549;
var hashCode = 1359330549;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(_suffix);
hashCode = hashCode * -1521134295 + EqualityComparer<int[]>.Default.GetHashCode(_version);
return hashCode;
Expand Down
2 changes: 1 addition & 1 deletion LifeUtils/LifeUtils/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//
// LifeUtils - LifeUtils - VersionInfo.cs
// 13.11.2018 12:12
// 19.11.2018 06:12

#endregion

Expand Down

0 comments on commit 68c5daa

Please sign in to comment.