forked from Azure/azure-iot-sdk-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in date deserialization of device method response (Azure#3097)
- Loading branch information
1 parent
f2a506f
commit 757fd5a
Showing
3 changed files
with
103 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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.Shared | ||
{ | ||
/// <summary> | ||
/// A class to initialize JsonSerializerSettings which can be applied to the project. | ||
/// </summary> | ||
public 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. | ||
/// </remarks> | ||
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings | ||
{ | ||
DateParseHandling = DateParseHandling.None | ||
}; | ||
|
||
/// <summary> | ||
/// Returns JsonSerializerSettings Func delegate | ||
/// </summary> | ||
public static Func<JsonSerializerSettings> GetJsonSerializerSettingsDelegate() | ||
{ | ||
return () => Settings; | ||
} | ||
} | ||
} |