Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
Moved serialization extensions methods to Serialization namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
peteraritchie committed May 25, 2016
1 parent 26272ca commit 8e904e4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
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
1 change: 1 addition & 0 deletions Rock.Core.UnitTests/Extensions/StringExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using NUnit.Framework;
using Rock.Extensions;
using Rock.Serialization;
using HashType = Rock.Cryptography.HashType;

namespace Rock.Core.UnitTests.Extensions
Expand Down
22 changes: 0 additions & 22 deletions Rock.Core/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,6 @@ public static bool IsNotNullAndEquals(this string originalString, string compare
}

/// <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);
}

/// <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>
/// Converts a string to a Hash of the specified type.
/// </summary>
/// <param name="value">The string to be hashed.</param>
Expand Down
1 change: 1 addition & 0 deletions Rock.Core/Rock.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<Compile Include="Serialization\DefaultBinarySerializer.cs" />
<Compile Include="Serialization\DefaultJsonSerializer.cs" />
<Compile Include="Serialization\DefaultXmlSerializer.cs" />
<Compile Include="Serialization\SerializationExtensions.cs" />
<Compile Include="StringFormatting\FormatToStringExtension.cs" />
<Compile Include="Immutable\Semimutable.cs" />
<Compile Include="Net\Http\DefaultHttpClientFactory.cs" />
Expand Down
27 changes: 27 additions & 0 deletions Rock.Core/Serialization/SerializationExtensions.cs
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);
}
}
}

0 comments on commit 8e904e4

Please sign in to comment.