This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved serialization extensions methods to Serialization namespace
- Loading branch information
1 parent
26272ca
commit 8e904e4
Showing
5 changed files
with
35 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[*.cs] | ||
indent_style=space | ||
indent_size=4 | ||
[*.config] | ||
indent_style=space | ||
indent_size=4 |
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,27 @@ | ||
namespace Rock.Serialization | ||
{ | ||
public static class SerializationExtensions | ||
{ | ||
/// <summary> | ||
/// Deserializes an XML string into an object of type T. | ||
/// </summary> | ||
/// <typeparam name="T">The type of object represented by this string</typeparam> | ||
/// <param name="str">The XML string to deserialize</param> | ||
/// <returns>An object of type T</returns> | ||
public static T FromXml<T>(this string str) | ||
{ | ||
return DefaultXmlSerializer.Current.DeserializeFromString<T>(str); | ||
} | ||
|
||
/// <summary> | ||
/// Deserializes a JSON string into an object of type T. | ||
/// </summary> | ||
/// <typeparam name="T">The type of object represented by this string</typeparam> | ||
/// <param name="str">The JSON string to deserialize</param> | ||
/// <returns>An object of type T</returns> | ||
public static T FromJson<T>(this string str) | ||
{ | ||
return DefaultJsonSerializer.Current.DeserializeFromString<T>(str); | ||
} | ||
} | ||
} |