Skip to content

Commit 660214a

Browse files
authored
Update README.md
1 parent 26ced79 commit 660214a

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,60 @@ You can use SharpConfig to read, modify and save configuration files and streams
1010

1111
Minimalistic, fully portable ([.NET Standard 2.0](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0#select-net-standard-version)), zero package dependencies.
1212

13-
[![Homepage](https://img.shields.io/badge/Homepage-blue)](https://dervis.de/sharpconfig)
13+
[![Website](https://img.shields.io/badge/Homepage-blue)](https://sharpconfig.org)
1414
[![NuGet Version](https://img.shields.io/nuget/v/sharpconfig)](https://www.nuget.org/packages/sharpconfig)
1515
[![NuGet Downloads](https://img.shields.io/nuget/dt/sharpconfig)](https://www.nuget.org/packages/sharpconfig)
1616
[![.NET](https://github.com/cdervis/SharpConfig/actions/workflows/dotnet.yml/badge.svg)](https://github.com/cdervis/SharpConfig/actions/workflows/dotnet.yml)
1717

1818
</div>
1919

20-
---
21-
22-
Install via:
20+
## Install
2321

2422
- .NET CLI: `> dotnet add package sharpconfig`
2523
- Package Manager: `> NuGet\Install-Package sharpconfig`
2624
- [Download latest](https://github.com/cdervis/SharpConfig/archive/refs/tags/v3.2.9.1.zip)
2725

26+
## Example
27+
28+
```ini
29+
# An example configuration:
30+
31+
[General]
32+
# a comment
33+
SomeString = Hello World!
34+
SomeInteger = 10 # an inline comment
35+
SomeFloat = 20.05
36+
SomeBoolean = true
37+
SomeArray = { 1, 2, 3 }
38+
Day = Monday
39+
40+
[Person]
41+
Name = Peter
42+
Age = 50
43+
```
44+
45+
To read these values, your C# code would look like:
46+
47+
```csharp
48+
var config = Configuration.LoadFromFile("sample.cfg");
49+
var section = config["General"];
50+
51+
string someString = section["SomeString"].StringValue;
52+
int someInteger = section["SomeInteger"].IntValue;
53+
float someFloat = section["SomeFloat"].FloatValue;
54+
bool someBool = section["SomeBoolean"].BoolValue;
55+
int[] someIntArray = section["SomeArray"].IntValueArray;
56+
string[] someStringArray = section["SomeArray"].StringValueArray;
57+
DayOfWeek day = section["Day"].GetValue<DayOfWeek>();
58+
59+
// Entire user-defined objects can be created from sections and vice versa.
60+
var person = config["Person"].ToObject<Person>();
61+
// ...
62+
```
63+
64+
---
65+
2866
## Documentation
2967

30-
The documentation is available on the [website](https://dervis.de/sharpconfig).
68+
The full documentation is available on the [website](https://sharpconfig.org).
3169

0 commit comments

Comments
 (0)