summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.AspNet/Clients/OAuth2/JsonHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.AspNet/Clients/OAuth2/JsonHelper.cs')
-rw-r--r--src/DotNetOpenAuth.AspNet/Clients/OAuth2/JsonHelper.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.AspNet/Clients/OAuth2/JsonHelper.cs b/src/DotNetOpenAuth.AspNet/Clients/OAuth2/JsonHelper.cs
new file mode 100644
index 0000000..a7ff79e
--- /dev/null
+++ b/src/DotNetOpenAuth.AspNet/Clients/OAuth2/JsonHelper.cs
@@ -0,0 +1,37 @@
+//-----------------------------------------------------------------------
+// <copyright file="JsonHelper.cs" company="Microsoft">
+// Copyright (c) Microsoft. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.AspNet.Clients {
+ using System;
+ using System.IO;
+ using System.Runtime.Serialization.Json;
+
+ /// <summary>
+ /// The json helper.
+ /// </summary>
+ internal static class JsonHelper {
+ #region Public Methods and Operators
+
+ /// <summary>
+ /// The deserialize.
+ /// </summary>
+ /// <param name="stream">
+ /// The stream.
+ /// </param>
+ /// <typeparam name="T">The type of the value to deserialize.</typeparam>
+ /// <returns>
+ /// The deserialized value.
+ /// </returns>
+ public static T Deserialize<T>(Stream stream) where T : class {
+ Requires.NotNull(stream, "stream");
+
+ var serializer = new DataContractJsonSerializer(typeof(T));
+ return (T)serializer.ReadObject(stream);
+ }
+
+ #endregion
+ }
+}