Skip to content

Commit 704d6e4

Browse files
committed
Cleanup: Inline variable declaration
1 parent 670ead2 commit 704d6e4

21 files changed

+43
-87
lines changed

src/Exceptionless/Configuration/ExceptionlessConfiguration.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,7 @@ public void RemovePlugin<T>() where T : IEventPlugin {
485485
/// </summary>
486486
/// <param name="key">The key for the plugin to be removed.</param>
487487
public void RemovePlugin(string key) {
488-
PluginRegistration plugin;
489-
if (_plugins.TryRemove(key, out plugin))
488+
if (_plugins.TryRemove(key, out var plugin))
490489
plugin.Dispose();
491490
}
492491

src/Exceptionless/Extensions/CollectionEqualityExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public static bool CollectionEquals<TValue>(this IDictionary<string, TValue> sou
4747
foreach (var key in source.Keys) {
4848
var sourceValue = source[key];
4949

50-
TValue otherValue;
51-
if (!other.TryGetValue(key, out otherValue)) {
50+
if (!other.TryGetValue(key, out var otherValue)) {
5251
return false;
5352
}
5453

src/Exceptionless/Extensions/DataDictionaryExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public static T GetValue<T>(this DataDictionary items, string key, IJsonSerializ
1414
if (String.IsNullOrEmpty(key))
1515
throw new ArgumentNullException(nameof(key));
1616

17-
object data;
18-
if (!items.TryGetValue(key, out data))
17+
if (!items.TryGetValue(key, out object data))
1918
throw new KeyNotFoundException($"The key '{key}' was not found.");
2019

2120
if (data == null || data is T)

src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ public static void ReadFromAppSettings(this ExceptionlessConfiguration config) {
380380
if (IsValidApiKey(apiKey))
381381
config.ApiKey = apiKey;
382382

383-
bool enabled;
384-
if (Boolean.TryParse(ConfigurationManager.AppSettings["Exceptionless:Enabled"], out enabled) && !enabled)
383+
if (Boolean.TryParse(ConfigurationManager.AppSettings["Exceptionless:Enabled"], out bool enabled) && !enabled)
385384
config.Enabled = false;
386385

387386
string serverUrl = ConfigurationManager.AppSettings["Exceptionless:ServerUrl"];
@@ -399,13 +398,11 @@ public static void ReadFromEnvironmentalVariables(this ExceptionlessConfiguratio
399398
if (IsValidApiKey(apiKey))
400399
config.ApiKey = apiKey;
401400

402-
bool enabled;
403-
if (Boolean.TryParse(GetEnvironmentalVariable("Exceptionless:Enabled") ?? GetEnvironmentalVariable("Exceptionless__Enabled"), out enabled) && !enabled)
401+
if (Boolean.TryParse(GetEnvironmentalVariable("Exceptionless:Enabled") ?? GetEnvironmentalVariable("Exceptionless__Enabled"), out bool enabled) && !enabled)
404402
config.Enabled = false;
405403

406-
bool processQueueOnCompletedRequest;
407404
string processQueueOnCompletedRequestValue = GetEnvironmentalVariable("Exceptionless:ProcessQueueOnCompletedRequest") ??
408-
GetEnvironmentalVariable("Exceptionless__ProcessQueueOnCompletedRequest");
405+
GetEnvironmentalVariable("Exceptionless__ProcessQueueOnCompletedRequest");
409406

410407
// if we are running in a serverless environment default this config to true
411408
if (String.IsNullOrEmpty(processQueueOnCompletedRequestValue)) {
@@ -419,7 +416,7 @@ public static void ReadFromEnvironmentalVariables(this ExceptionlessConfiguratio
419416
processQueueOnCompletedRequestValue = Boolean.TrueString;
420417
}
421418

422-
if (Boolean.TryParse(processQueueOnCompletedRequestValue, out processQueueOnCompletedRequest) && processQueueOnCompletedRequest)
419+
if (Boolean.TryParse(processQueueOnCompletedRequestValue, out bool processQueueOnCompletedRequest) && processQueueOnCompletedRequest)
423420
config.ProcessQueueOnCompletedRequest = true;
424421

425422
string serverUrl = GetEnvironmentalVariable("Exceptionless:ServerUrl") ?? GetEnvironmentalVariable("Exceptionless__ServerUrl");

src/Exceptionless/Extensions/FileStorageExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public static int GetAttempts(this ObjectInfo info) {
5353
if (parts.Length != 3)
5454
return 0;
5555

56-
int attempts;
57-
return !Int32.TryParse(parts[1], out attempts) ? 0 : attempts;
56+
return !Int32.TryParse(parts[1], out int attempts) ? 0 : attempts;
5857
}
5958

6059
public static bool LockFile(this IObjectStorage storage, ObjectInfo info) {

src/Exceptionless/Extensions/StringExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ internal static bool ToBoolean(this string input, bool @default = false) {
7777

7878
input = input.ToLowerInvariant().Trim();
7979

80-
bool value;
81-
if (bool.TryParse(input, out value))
80+
if (bool.TryParse(input, out bool value))
8281
return value;
8382

8483
if (String.Equals(input, "yes") || String.Equals(input, "1"))

src/Exceptionless/Logging/FileExceptionlessLog.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,14 @@ public void Flush() {
142142

143143
try {
144144
using (var writer = GetWriter(append)) {
145-
LogEntry entry;
146-
while (_buffer.TryDequeue(out entry)) {
145+
while (_buffer.TryDequeue(out var entry)) {
147146
if (entry != null && entry.LogLevel >= MinimumLogLevel)
148147
writer.Value.WriteLine($"{FormatLongDate(entry.Timestamp)} {entry.LogLevel.ToString().PadRight(5)} {entry.Message}");
149148
}
150149
}
151150
} catch (Exception ex) {
152151
System.Diagnostics.Trace.TraceError("Unable flush the logs. " + ex.Message);
153-
LogEntry entry;
154-
while (_buffer.TryDequeue(out entry)) {
152+
while (_buffer.TryDequeue(out var entry)) {
155153
System.Diagnostics.Trace.WriteLine(entry);
156154
}
157155
}

src/Exceptionless/Logging/InMemoryExceptionlessLog.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public InMemoryExceptionlessLog(int maxEntriesToStore) : this() {
2121

2222
public InMemoryExceptionlessLog(string maxEntriesToStore)
2323
: this() {
24-
int value;
25-
if (Int32.TryParse(maxEntriesToStore, out value))
24+
if (Int32.TryParse(maxEntriesToStore, out int value))
2625
MaxEntriesToStore = value;
2726
}
2827

src/Exceptionless/Models/Collections/DataDictionary.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,23 @@ public DataDictionary(IEnumerable<KeyValuePair<string, object>> values) : base(S
1111
}
1212

1313
public object GetValueOrDefault(string key) {
14-
object value;
15-
return TryGetValue(key, out value) ? value : null;
14+
return TryGetValue(key, out object value) ? value : null;
1615
}
1716

1817
public object GetValueOrDefault(string key, object defaultValue) {
19-
object value;
20-
return TryGetValue(key, out value) ? value : defaultValue;
18+
return TryGetValue(key, out object value) ? value : defaultValue;
2119
}
2220

2321
public object GetValueOrDefault(string key, Func<object> defaultValueProvider) {
24-
object value;
25-
return TryGetValue(key, out value) ? value : defaultValueProvider();
22+
return TryGetValue(key, out object value) ? value : defaultValueProvider();
2623
}
2724

2825
public string GetString(string name) {
2926
return GetString(name, String.Empty);
3027
}
3128

3229
public string GetString(string name, string @default) {
33-
object value;
34-
35-
if (!TryGetValue(name, out value))
30+
if (!TryGetValue(name, out object value))
3631
return @default;
3732

3833
if (value is string)

src/Exceptionless/Models/Collections/ObservableDictionary.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public void Add(KeyValuePair<TKey, TValue> item) {
3434
}
3535

3636
public bool Remove(TKey key) {
37-
TValue value = default(TValue);
38-
bool success = _dictionary.TryRemove(key, out value);
37+
bool success = _dictionary.TryRemove(key, out var value);
3938
if (success)
4039
OnChanged(new ChangedEventArgs<KeyValuePair<TKey, TValue>>(new KeyValuePair<TKey, TValue>(key, value), ChangedAction.Remove));
4140

0 commit comments

Comments
 (0)