1
0
Fork 0
mirror of https://github.com/sbrl/PolyFeed.git synced 2024-11-22 06:23:02 +00:00

Start on a JSON provider, but it's not finished yet

This commit is contained in:
Starbeamrainbowlabs 2019-08-11 16:14:25 +01:00
parent 6944d87726
commit a15f1157f0
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 48 additions and 4 deletions

View file

@ -26,6 +26,7 @@ namespace PolyFeed.ParserProviders
/// <param name="feed">The output feed writer that output should be written to.</param> /// <param name="feed">The output feed writer that output should be written to.</param>
/// <param name="xml">The underlying XML feed try not to use this unless you *really* have to.</param> /// <param name="xml">The underlying XML feed try not to use this unless you *really* have to.</param>
void SetOutputFeed(AtomFeedWriter feed, XmlWriter xml); void SetOutputFeed(AtomFeedWriter feed, XmlWriter xml);
/// <summary> /// <summary>
/// Parses a web response that's paired with a given <see cref="FeedSource" />. /// Parses a web response that's paired with a given <see cref="FeedSource" />.
/// </summary> /// </summary>

View file

@ -0,0 +1,45 @@
using System;
using System.Net;
using System.Threading.Tasks;
using System.Xml;
using Microsoft.SyndicationFeed.Atom;
using System.Json;
using System.IO;
namespace PolyFeed.ParserProviders
{
public class JsonParserProvider : IParserProvider
{
private XmlWriter xml = null;
private AtomFeedWriter feed = null;
public string Identifier => "json";
public JsonParserProvider() {
}
public void SetOutputFeed(AtomFeedWriter inFeed, XmlWriter inXml) {
xml = inXml;
feed = inFeed;
}
public async Task ParseWebResponse(FeedSource source, WebResponse response)
{
string jsonText;
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
jsonText = await reader.ReadToEndAsync();
JsonValue jsonValue = JsonValue.Parse(jsonText);
JsonObject json = jsonValue as JsonObject;
if (json == null)
throw new ApplicationException("Error: Failed to parse the JSON into an object.");
throw new NotImplementedException("Error %01: Not implemented :-/");
}
}
}

View file

@ -126,15 +126,13 @@
<Reference Include="Fizzler.Systems.HtmlAgilityPack"> <Reference Include="Fizzler.Systems.HtmlAgilityPack">
<HintPath>..\packages\Fizzler.Systems.HtmlAgilityPack.1.2.0\lib\netstandard1.3\Fizzler.Systems.HtmlAgilityPack.dll</HintPath> <HintPath>..\packages\Fizzler.Systems.HtmlAgilityPack.1.2.0\lib\netstandard1.3\Fizzler.Systems.HtmlAgilityPack.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SyndicationFeed.ReaderWriter"> <Reference Include="Microsoft.SyndicationFeed.ReaderWriter">
<HintPath>..\packages\Microsoft.SyndicationFeed.ReaderWriter.1.0.2\lib\netstandard1.3\Microsoft.SyndicationFeed.ReaderWriter.dll</HintPath> <HintPath>..\packages\Microsoft.SyndicationFeed.ReaderWriter.1.0.2\lib\netstandard1.3\Microsoft.SyndicationFeed.ReaderWriter.dll</HintPath>
</Reference> </Reference>
<Reference Include="Nett"> <Reference Include="Nett">
<HintPath>..\packages\Nett.0.13.0\lib\net40\Nett.dll</HintPath> <HintPath>..\packages\Nett.0.13.0\lib\net40\Nett.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
@ -154,6 +152,7 @@
<Compile Include="Helpers\ReflectionHelpers.cs" /> <Compile Include="Helpers\ReflectionHelpers.cs" />
<Compile Include="ParserProviders\IParserProvider.cs" /> <Compile Include="ParserProviders\IParserProvider.cs" />
<Compile Include="ParserProviders\HtmlParserProvider.cs" /> <Compile Include="ParserProviders\HtmlParserProvider.cs" />
<Compile Include="ParserProviders\JsonParserProvider.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />

View file

@ -8,7 +8,6 @@
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net47" /> <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net47" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="net47" /> <package id="NETStandard.Library" version="2.0.3" targetFramework="net47" />
<package id="Nett" version="0.13.0" targetFramework="net47" /> <package id="Nett" version="0.13.0" targetFramework="net47" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net47" />
<package id="System.AppContext" version="4.3.0" targetFramework="net47" /> <package id="System.AppContext" version="4.3.0" targetFramework="net47" />
<package id="System.Collections" version="4.3.0" targetFramework="net47" /> <package id="System.Collections" version="4.3.0" targetFramework="net47" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net47" /> <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net47" />