Skip to content

Commit

Permalink
Merge pull request #133 from DevyusCode/doc
Browse files Browse the repository at this point in the history
Updated documentation
  • Loading branch information
lpeyr authored Jul 29, 2023
2 parents 988e6be + dfdc395 commit 5cfcbe0
Show file tree
Hide file tree
Showing 203 changed files with 1,619 additions and 984 deletions.
12 changes: 9 additions & 3 deletions Documentation/.vitepress/cache/deps/_metadata.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"hash": "1cd17bc6",
"browserHash": "cc3e279a",
"hash": "44ac7ce3",
"browserHash": "3699f0c8",
"optimized": {
"vue": {
"src": "../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "1771e818",
"fileHash": "380e6e7c",
"needsInterop": false
},
"vitepress > @vue/devtools-api": {
"src": "../../../node_modules/@vue/devtools-api/lib/esm/index.js",
"file": "vitepress___@vue_devtools-api.js",
"fileHash": "944a23b0",
"needsInterop": false
}
},
Expand Down
162 changes: 162 additions & 0 deletions Documentation/.vitepress/cache/deps/vitepress___@vue_devtools-api.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Documentation/.vitepress/cache/deps/vue.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Documentation/.vitepress/cache/deps/vue.js.map

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions Documentation/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,20 @@ function sidebar() {
},
],
},
{
text: "Helpers",
collapsed: false,
items: [
{
text: "JsonHelper",
link: "/core/json-helper",
},
{
text: "XmlHelper",
link: "/core/xml-helper",
},
],
},
{
text: "Internet",
collapsed: false,
Expand Down
98 changes: 98 additions & 0 deletions Documentation/core/json-helper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# JsonHelper

This page is about the `JsonHelper` class available in PeyrSharp.Core.
You can find here all of its methods.

::: info
This class is `static`.
:::

## Compatibility

The `JsonHelper` class is part of the `PeyrSharp.Core` module, which is compatible with all of these frameworks and platforms:

| Package/Platform | Windows | macOS | Linux + others |
| ---------------- | ---------- | ---------- | -------------- |
| Core ||||
| **Framework** | **.NET 5** | **.NET 6** | **.NET 7** |
| Core ||||

## Methods

### LoadFromJson\<T>(fileName)

#### Definition

The `LoadFromJson<T>()` method loads an object from a JSON file.

#### Type Parameters

| Type | Meaning |
| ---- | ------------------------------- |
| `T` | The type of the object to save. |

#### Arguments

| Type | Name | Meaning |
| -------- | ---------- | ---------------------------------- |
| `string` | `fileName` | The name of the file to load from. |

#### Returns

The object loaded from the file.

#### Usage

```c#
using PeyrSharp.Core;
using System.IO;
using System.Text.Json;

// Load the person from the JSON file
Person person = JsonHelper.LoadFromJson<Person>("person.json");

// Print the person's name and age
Console.WriteLine($"Name: {person.Name}, Age: {person.Age}");
```

### SaveAsJson\<T>(obj, fileName)

#### Definition

The `SaveAsJson()` method saves an object as a JSON file.

#### Type Parameters

| Type | Meaning |
| ---- | ------------------------------- |
| `T` | The type of the object to save. |

#### Arguments

| Type | Name | Meaning |
| -------- | ---------- | -------------------------------- |
| `T` | `obj` | The object to save. |
| `string` | `fileName` | The name of the file to save to. |

#### Usage

```c#
using PeyrSharp.Core;
using System.IO;
using System.Text.Json;

public static void Main()
{
// Create an object to save
MyObject obj = new MyObject();

// Save the object as a JSON file
JsonHelper.SaveAsJson(obj, "output.json");
}

public class MyObject
{
public string Name { get; set; }
public int Age { get; set; }
}
```
Loading

0 comments on commit 5cfcbe0

Please sign in to comment.