-
Notifications
You must be signed in to change notification settings - Fork 1
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
9274a01
commit dab2d47
Showing
4 changed files
with
82 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# DragonFruit.Data.Serializers.Html | ||
A serializer adding `HtmlDocument` support to DragonFruit.Data | ||
|
||
[![Latest Nuget](https://img.shields.io/nuget/v/DragonFruit.Data.Serializers.Html?label=DragonFruit.Data.Serializers.Html&logo=nuget)](https://nuget.org/packages/DragonFruit.Data.Serializers.Html) | ||
[![DragonFruit Discord](https://img.shields.io/discord/482528405292843018?label=Discord&style=popout)](https://discord.gg/VA26u5Z) | ||
|
||
## Overview | ||
DragonFruit.Data.Serializers.Html is a serializer for DragonFruit.Data that allows `HtmlDocument` to be used as a response type. | ||
`HtmlDocument` functionality is provided by [HtmlAgilityPack](https://github.com/zzzprojects/html-agility-pack), an open-source, MIT-licensed HTML parser. | ||
|
||
## Usage/Getting Started | ||
To get started install the [NuGet package](https://nuget.org/packages/DragonFruit.Data.Serializers.Html) alongside `DragonFruit.Data` and register it as a serializer. | ||
|
||
```csharp | ||
using DragonFruit.Data; | ||
using DragonFruit.Data.Serializers.Html; | ||
|
||
namespace DataExample; | ||
|
||
public static class Program | ||
{ | ||
internal static ApiClient Client = new ApiClient<ApiJsonSerializer> | ||
{ | ||
UserAgent = "DataExample" | ||
}; | ||
|
||
static Program() | ||
{ | ||
// register html serializer defaults | ||
HtmlSerializer.RegisterDefaults(); | ||
} | ||
|
||
public static async Task Main(string[] args) | ||
{ | ||
var html = await Client.PerformAsync<HtmlDocument>("https://example.com"); | ||
|
||
// html can now be manipulated as needed | ||
} | ||
|
||
} | ||
``` |
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,33 @@ | ||
# DragonFruit.Data.Serializers.Newtonsoft | ||
A serializer adding `Newtonsoft.Json` support to DragonFruit.Data | ||
|
||
[![Latest Nuget](https://img.shields.io/nuget/v/DragonFruit.Data.Serializers.Newtonsoft?label=DragonFruit.Data.Serializers.Newtonsoft&logo=nuget)](https://nuget.org/packages/DragonFruit.Data.Serializers.Newtonsoft) | ||
[![DragonFruit Discord](https://img.shields.io/discord/482528405292843018?label=Discord&style=popout)](https://discord.gg/VA26u5Z) | ||
|
||
## Overview | ||
DragonFruit.Data.Serializers.Newtonsoft is a generic serializer for DragonFruit.Data that allows Newtonsoft.Json to be used as a generic JSON serializer. | ||
|
||
## Usage/Getting Started | ||
To get started install the [NuGet package](https://nuget.org/packages/DragonFruit.Data.Serializers.Newtonsoft) and replace the default serializer with the Newtonsoft one. | ||
|
||
```csharp | ||
using DragonFruit.Data; | ||
using DragonFruit.Data.Serializers.Newtonsoft; | ||
|
||
namespace DataExample; | ||
|
||
public static class Program | ||
{ | ||
internal static ApiClient Client = new ApiClient<NewtonsoftJsonSerializer> | ||
{ | ||
UserAgent = "DataExample" | ||
}; | ||
|
||
static Program() | ||
{ | ||
// optionally, register serializer defaults to always deserialize JObjects with Newtonsoft | ||
// using this will allow for a different serializer to be used for other types, while not breaking JObject support. | ||
NewtonsoftJsonSerializer.RegisterDefaults(); | ||
} | ||
} | ||
``` |