-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply JsonSerializerSettings to hub device (#3107)
- Loading branch information
1 parent
f5b5b07
commit c1d6e97
Showing
6 changed files
with
132 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
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,36 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace Microsoft.Azure.Devices.Client | ||
{ | ||
/// <summary> | ||
/// A class to initialize JsonSerializerSettings which can be applied to the project. | ||
/// </summary> | ||
internal static class JsonSerializerSettingsInitializer | ||
{ | ||
/// <summary> | ||
/// A static instance of JsonSerializerSettings which sets DateParseHandling to None. | ||
/// </summary> | ||
/// <remarks> | ||
/// By default, serializing/deserializing with Newtonsoft.Json will try to parse date-formatted | ||
/// strings to a date type, which drops trailing zeros in the microseconds date portion. By | ||
/// specifying DateParseHandling with None, the original string will be read as-is. For more details | ||
/// about the known issue, see https://github.com/JamesNK/Newtonsoft.Json/issues/1511. | ||
/// </remarks> | ||
private static readonly JsonSerializerSettings s_settings = new JsonSerializerSettings | ||
{ | ||
DateParseHandling = DateParseHandling.None | ||
}; | ||
|
||
/// <summary> | ||
/// Returns JsonSerializerSettings Func delegate | ||
/// </summary> | ||
internal static Func<JsonSerializerSettings> GetJsonSerializerSettingsDelegate() | ||
{ | ||
return () => s_settings; | ||
} | ||
} | ||
} |
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