-
Notifications
You must be signed in to change notification settings - Fork 9
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
bdec00f
commit c9502ed
Showing
14 changed files
with
135 additions
and
53 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 |
---|---|---|
@@ -1,10 1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Castle.Core" version="3.3.3" targetFramework="net452" /> | ||
<package id="FastMember" version="1.0.0.11" targetFramework="net452" /> | ||
<package id="FastMember.Signed" version="1.0.0.11" targetFramework="net45" /> | ||
<package id="FastMember" version="1.1.0" targetFramework="net45" /> | ||
<package id="FastMember.Signed" version="1.1.0" targetFramework="net45" /> | ||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" /> | ||
<package id="NuProj" version="0.11.14-beta" targetFramework="net45" developmentDependency="true" /> | ||
<package id="NuProj.Common" version="0.11.14-beta" targetFramework="net45" developmentDependency="true" /> | ||
<package id="System.Collections.Immutable" version="1.1.37" targetFramework="net452" /> | ||
<package id="System.Collections.Immutable" version="1.3.0" targetFramework="net45" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Castle.Core" version="3.3.3" targetFramework="net452" /> | ||
<package id="FastMember" version="1.0.0.11" targetFramework="net452" /> | ||
<package id="FastMember.Signed" version="1.0.0.11" targetFramework="net45" /> | ||
<package id="FastMember" version="1.1.0" targetFramework="net45" /> | ||
<package id="FastMember.Signed" version="1.1.0" targetFramework="net45" /> | ||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" /> | ||
<package id="NuProj" version="0.11.14-beta" targetFramework="net45" developmentDependency="true" /> | ||
<package id="NuProj.Common" version="0.11.14-beta" targetFramework="net45" developmentDependency="true" /> | ||
<package id="System.Collections.Immutable" version="1.1.37" targetFramework="net452" /> | ||
<package id="System.Collections.Immutable" version="1.3.0" targetFramework="net45" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Castle.Core" version="3.3.3" targetFramework="net452" /> | ||
<package id="FastMember.Signed" version="1.0.0.11" targetFramework="net452" /> | ||
<package id="FastMember.Signed" version="1.1.0" targetFramework="net452" /> | ||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" /> | ||
<package id="NuProj.Common" version="0.11.14-beta" targetFramework="net452" developmentDependency="true" /> | ||
<package id="System.Collections.Immutable" version="1.1.37" targetFramework="net452" /> | ||
<package id="System.Collections.Immutable" version="1.3.0" targetFramework="net452" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,26 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Dynamic; | ||
using TrackerDog.Serialization.Json; | ||
|
||
namespace TrackerDog | ||
{ | ||
internal static class ObjectExtensions | ||
{ | ||
public static object CloneIt(this object some, Type type) | ||
{ | ||
JsonSerializerSettings serializerSettings = new JsonSerializerSettings | ||
{ | ||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore, | ||
ContractResolver = new DynamicObjectContractResolver() | ||
}; | ||
|
||
if (some is IDynamicMetaObjectProvider) | ||
serializerSettings.Converters.Add(new DynamicObjectWithDeclaredPropertiesConverter()); | ||
|
||
string json = JsonConvert.SerializeObject(some, serializerSettings); | ||
|
||
return JsonConvert.DeserializeObject(json, type, serializerSettings); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
TrackerDog/Serialization/Json/DynamicObjectContractResolver.cs
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,20 @@ | ||
using Newtonsoft.Json.Serialization; | ||
using System; | ||
using System.Dynamic; | ||
|
||
namespace TrackerDog.Serialization.Json | ||
{ | ||
internal class DynamicObjectContractResolver : CamelCasePropertyNamesContractResolver | ||
{ | ||
protected override JsonContract CreateContract(Type objectType) | ||
{ | ||
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(objectType)) | ||
{ | ||
return CreateObjectContract(objectType); | ||
} | ||
|
||
return base.CreateContract(objectType); | ||
} | ||
|
||
} | ||
} |
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
Oops, something went wrong.