-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* COREX-611 - LLM Suggestions Added EndpointConverter to JsonSerializerSettings to customize serialization of Sysmte.Net.IPEndPoint * Fix namespace change for tests
- Loading branch information
1 parent
4c5ebbf
commit a0e7c89
Showing
6 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Logging/Loggly/Loggly/SerializerSettings/EndpointConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
|
||
namespace EMG.Extensions.Logging.Loggly.SerializerSettings; | ||
|
||
public class EndpointConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(System.Net.IPEndPoint); | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
if (value is System.Net.IPEndPoint endpoint) | ||
{ | ||
writer.WriteValue(endpoint.ToString()); | ||
} | ||
else | ||
{ | ||
writer.WriteValue(value); | ||
} | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
6 changes: 4 additions & 2 deletions
6
...ng/Loggly/Loggly/FormattedIdConverter .cs → ...rializerSettings/FormattedIdConverter .cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/Logging/Loggly/Loggly/SerializerSettings/JsonSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace EMG.Extensions.Logging.Loggly.SerializerSettings; | ||
|
||
public static class JsonSettings | ||
{ | ||
public static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings | ||
{ | ||
TypeNameHandling = TypeNameHandling.None, | ||
NullValueHandling = NullValueHandling.Ignore, | ||
Formatting = Formatting.None, | ||
DefaultValueHandling = DefaultValueHandling.Include, | ||
DateTimeZoneHandling = DateTimeZoneHandling.Utc, | ||
DateFormatHandling = DateFormatHandling.IsoDateFormat, | ||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore, | ||
Converters = { new FormattedIdConverter(), new EndpointConverter() } | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters