-Added ICloneable and DeepClone to JToken

-Changed DeepEquals to take into account possible floating point errors
This commit is contained in:
JamesNK
2010-12-27 21:25:06 +00:00
parent f32e1f53c5
commit 3ad33f7329
4 changed files with 111 additions and 4 deletions
+22 -3
View File
@@ -43,10 +43,13 @@ namespace Newtonsoft.Json.Linq
/// Represents an abstract JSON token.
/// </summary>
public abstract class JToken : IJEnumerable<JToken>, IJsonLineInfo
#if !(NET35 || NET20 || SILVERLIGHT)
, IDynamicMetaObjectProvider
#if !SILVERLIGHT
, ICloneable
#endif
{
#if !(NET35 || NET20 || SILVERLIGHT)
, IDynamicMetaObjectProvider
#endif
{
private JContainer _parent;
internal JToken _next;
private static JTokenEqualityComparer _equalityComparer;
@@ -1298,5 +1301,21 @@ namespace Newtonsoft.Json.Linq
return GetMetaObject(parameter);
}
#endif
#if !SILVERLIGHT
object ICloneable.Clone()
{
return DeepClone();
}
#endif
/// <summary>
/// Creates a new instance of the <see cref="JToken"/>. All child tokens are recursively cloned.
/// </summary>
/// <returns>A new instance of the <see cref="JToken"/>.</returns>
public JToken DeepClone()
{
return CloneToken();
}
}
}