diff --git a/src/Exceptionless/Extensions/DataDictionaryExtensions.cs b/src/Exceptionless/Extensions/DataDictionaryExtensions.cs index f22a7725..36170059 100644 --- a/src/Exceptionless/Extensions/DataDictionaryExtensions.cs +++ b/src/Exceptionless/Extensions/DataDictionaryExtensions.cs @@ -104,7 +104,7 @@ public static void AddObject(this IData data, ExtendedDataInfo info, Exceptionle : client.Configuration.DataExclusions.ToArray(); string name = !String.IsNullOrWhiteSpace(info.Name) ? info.Name.Trim() : null; - Type dataType = info.Data.GetType(); + var dataType = info.Data.GetType(); if (String.IsNullOrEmpty(name)) { name = dataType.Name; int index = 1; @@ -115,10 +115,7 @@ public static void AddObject(this IData data, ExtendedDataInfo info, Exceptionle } if (dataType == typeof(bool) || dataType == typeof(string) || dataType.IsNumeric()) { - if (data.Data.ContainsKey(name)) - data.Data[name] = info.Data; - else - data.Data.Add(name, info.Data); + data.Data[name] = info.Data; return; } @@ -129,7 +126,7 @@ public static void AddObject(this IData data, ExtendedDataInfo info, Exceptionle json = info.Data.ToString(); } else { var serializer = client.Configuration.Resolver.GetJsonSerializer(); - json = serializer.Serialize(info.Data, exclusions, info.MaxDepthToSerialize.HasValue ? info.MaxDepthToSerialize.Value : 5, info.IgnoreSerializationErrors); + json = serializer.Serialize(info.Data, exclusions, info.MaxDepthToSerialize.GetValueOrDefault(5), info.IgnoreSerializationErrors); } } catch (Exception ex) { json = ex.ToString(); @@ -138,10 +135,7 @@ public static void AddObject(this IData data, ExtendedDataInfo info, Exceptionle if (String.IsNullOrEmpty(json)) return; - if (data.Data.ContainsKey(name)) - data.Data[name] = json; - else - data.Data.Add(name, json); + data.Data[name] = json; } } } \ No newline at end of file diff --git a/src/Exceptionless/Serializer/ExceptionlessContractResolver.cs b/src/Exceptionless/Serializer/ExceptionlessContractResolver.cs index 2a525f9d..09d87e9c 100644 --- a/src/Exceptionless/Serializer/ExceptionlessContractResolver.cs +++ b/src/Exceptionless/Serializer/ExceptionlessContractResolver.cs @@ -13,17 +13,17 @@ public ExceptionlessContractResolver(Func includePro } protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) { - JsonProperty property = base.CreateProperty(member, memberSerialization); + var property = base.CreateProperty(member, memberSerialization); if (_includeProperty == null) return property; - Predicate shouldSerialize = property.ShouldSerialize; + var shouldSerialize = property.ShouldSerialize; property.ShouldSerialize = obj => _includeProperty(property, obj) && (shouldSerialize == null || shouldSerialize(obj)); return property; } protected override JsonDictionaryContract CreateDictionaryContract(Type objectType) { - JsonDictionaryContract contract = base.CreateDictionaryContract(objectType); + var contract = base.CreateDictionaryContract(objectType); contract.DictionaryKeyResolver = propertyName => propertyName; return contract; } diff --git a/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs b/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs index 1373f375..2cc39981 100644 --- a/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs +++ b/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs @@ -58,19 +58,19 @@ protected override void Write(LogEventInfo logEvent) { if (!_client.Configuration.IsValid) return; - LogLevel minLogLevel = LogLevel.FromOrdinal(_client.Configuration.Settings.GetMinLogLevel(logEvent.LoggerName).Ordinal); + var minLogLevel = LogLevel.FromOrdinal(_client.Configuration.Settings.GetMinLogLevel(logEvent.LoggerName).Ordinal); if (logEvent.Level < minLogLevel) return; - var formattedMessage = RenderLogEvent(Layout, logEvent); + string formattedMessage = RenderLogEvent(Layout, logEvent); var builder = _client.CreateFromLogEvent(logEvent, formattedMessage); - var userIdentity = RenderLogEvent(UserIdentity, logEvent); - var userIdentityName = RenderLogEvent(UserIdentityName, logEvent); + string userIdentity = RenderLogEvent(UserIdentity, logEvent); + string userIdentityName = RenderLogEvent(UserIdentityName, logEvent); builder.Target.SetUserIdentity(userIdentity, userIdentityName); foreach (var field in Fields) { - var renderedField = RenderLogEvent(field.Layout, logEvent); + string renderedField = RenderLogEvent(field.Layout, logEvent); if (!String.IsNullOrWhiteSpace(renderedField)) builder.AddObject(renderedField, field.Name); }