-Added IJEnumerable. Changed JEnumerable and JToken to both implement IJEnumerable.

-Included missing JsonConverters from Newtonsoft.Json.Silverlight project.
This commit is contained in:
JamesNK
2008-08-23 04:56:24 +00:00
parent a6662b595d
commit c7d99fbd3f
5 changed files with 38 additions and 9 deletions
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Newtonsoft.Json.Linq
{
/// <summary>
/// Represents a collection of <see cref="JToken"/> objects.
/// </summary>
/// <typeparam name="T">The type of token</typeparam>
public interface IJEnumerable<T> : IEnumerable<T> where T : JToken
{
/// <summary>
/// Gets the <see cref="IJEnumerable{JToken}"/> with the specified key.
/// </summary>
/// <value></value>
IJEnumerable<JToken> this[object key] { get; }
}
}
+4 -4
View File
@@ -11,7 +11,7 @@ namespace Newtonsoft.Json.Linq
/// Represents a collection of <see cref="JToken"/> objects.
/// </summary>
/// <typeparam name="T">The type of token</typeparam>
public struct JEnumerable<T> : IEnumerable<T> where T : JToken
public struct JEnumerable<T> : IJEnumerable<T> where T : JToken
{
/// <summary>
/// An empty collection of <see cref="JToken"/> objects.
@@ -54,12 +54,12 @@ namespace Newtonsoft.Json.Linq
}
/// <summary>
/// Gets the <see cref="IEnumerable{JToken}"/> with the specified key.
/// Gets the <see cref="IJEnumerable{JToken}"/> with the specified key.
/// </summary>
/// <value></value>
public IEnumerable<JToken> this[object key]
public IJEnumerable<JToken> this[object key]
{
get { return Extensions.Values<T, JToken>(_enumerable, key); }
get { return new JEnumerable<JToken>(Extensions.Values<T, JToken>(_enumerable, key)); }
}
}
}
+6 -1
View File
@@ -38,7 +38,7 @@ namespace Newtonsoft.Json.Linq
/// <summary>
/// Represents an abstract JSON token.
/// </summary>
public abstract class JToken : IEnumerable<JToken>
public abstract class JToken : IJEnumerable<JToken>
{
private JContainer _parent;
internal JToken _next;
@@ -723,5 +723,10 @@ namespace Newtonsoft.Json.Linq
}
internal abstract int GetDeepHashCode();
IJEnumerable<JToken> IJEnumerable<JToken>.this[object key]
{
get { return Children()[key]; }
}
}
}
@@ -211,6 +211,11 @@
<Compile Include="..\Newtonsoft.Json\Utilities\ValidationUtils.cs">
<Link>Utilities\ValidationUtils.cs</Link>
</Compile>
<Compile Include="Converters\HtmlColorConverter.cs" />
<Compile Include="Converters\IsoDateTimeConverter.cs" />
<Compile Include="Converters\JavaScriptDateTimeConverter.cs" />
<Compile Include="Converters\JsonDateTimeSerializationMode.cs" />
<Compile Include="Converters\XmlNodeConverter.cs" />
<Compile Include="Identifier.cs" />
<Compile Include="JavaScriptConvert.cs" />
<Compile Include="JsonConverter.cs" />
@@ -230,6 +235,7 @@
<Compile Include="JsonWriter.cs" />
<Compile Include="JsonWriterException.cs" />
<Compile Include="Linq\Extensions.cs" />
<Compile Include="Linq\IJEnumerable.cs" />
<Compile Include="Linq\JArray.cs" />
<Compile Include="Linq\JConstructor.cs" />
<Compile Include="Linq\JContainer.cs" />
@@ -263,9 +269,6 @@
<Compile Include="Utilities\StringUtils.cs" />
<Compile Include="Utilities\ValidationUtils.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Converters\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
+2 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -76,6 +76,7 @@
<ItemGroup>
<Compile Include="JsonConverterAttribute.cs" />
<Compile Include="JsonObjectAttribute.cs" />
<Compile Include="Linq\IJEnumerable.cs" />
<Compile Include="Linq\JTokenEqualityComparer.cs" />
<Compile Include="MemberSerialization.cs" />
<Compile Include="ObjectCreationHandling.cs" />