-
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.
- Loading branch information
1 parent
6f8bcb3
commit 0cee985
Showing
24 changed files
with
193 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="StyleCop.Analyzers" version="1.0.0" targetFramework="portable45-net45+win8" developmentDependency="true" /> | ||
</packages> |
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
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="StyleCop.Analyzers" version="1.0.0" targetFramework="net45" developmentDependency="true" /> | ||
<package id="System.Threading.Thread" version="4.0.0" targetFramework="net462" /> | ||
</packages> |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> | ||
</configuration> |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="StyleCop.Analyzers" version="1.0.0" targetFramework="portable45-net45+win8" developmentDependency="true" /> | ||
</packages> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// <copyright>Copyright 2012-2017 Lawo AG (http://www.lawo.com).</copyright> | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
namespace Lawo.IO | ||
{ | ||
using System.IO; | ||
using System.Runtime.Serialization.Json; | ||
using System.Text; | ||
|
||
/// <summary>Serializes objects to the JavaScript Object Notation (JSON) and deserializes JSON data to objects. | ||
/// </summary> | ||
/// <threadsafety static="true" instance="false"/> | ||
public static class JsonSerializer | ||
{ | ||
/// <summary>Serializes objects to the JavaScript Object Notation (JSON).</summary> | ||
/// <typeparam name="T">The type to be serialized (data contract).</typeparam> | ||
/// <param name="data">The data contract object.</param> | ||
/// <returns>The serialized JSON string.</returns> | ||
public static string Serialize<T>(T data) | ||
{ | ||
using (var stream = new MemoryStream()) | ||
{ | ||
new DataContractJsonSerializer(typeof(T)).WriteObject(stream, data); | ||
stream.Position = 0; | ||
|
||
using (var reader = new StreamReader(stream)) | ||
{ | ||
return reader.ReadToEnd(); | ||
} | ||
} | ||
} | ||
|
||
/// <summary>Deserializes JSON data to objects.</summary> | ||
/// <typeparam name="T">The type to be deserialized (data contract).</typeparam> | ||
/// <param name="jsonData">The JSON string.</param> | ||
/// <returns>The data contract object.</returns> | ||
public static T Deserialize<T>(string jsonData) | ||
{ | ||
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonData))) | ||
{ | ||
return (T)new DataContractJsonSerializer(typeof(T)).ReadObject(stream); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.