-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creation of pick-ups and blips now optional
- Loading branch information
Showing
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FRFuel | ||
{ | ||
public class Config | ||
{ | ||
protected Dictionary<string, string> Entries { get; set; } | ||
|
||
public Config(string content) | ||
{ | ||
Entries = new Dictionary<string, string>(); | ||
|
||
if (content == null || content.Length == 0) | ||
{ | ||
return; | ||
} | ||
|
||
var splitted = content | ||
.Split('\n') | ||
.Where((line) => !line.Trim().StartsWith("#")) | ||
.Select((line) => line.Trim().Split('=')) | ||
.Where((line) => line.Length == 2); | ||
|
||
foreach (var tuple in splitted) | ||
{ | ||
Entries.Add(tuple[0], tuple[1]); | ||
} | ||
} | ||
|
||
public string Get(string key, string defaultValue = null) | ||
{ | ||
if (Entries.ContainsKey(key)) | ||
{ | ||
return Entries[key]; | ||
} | ||
|
||
return defaultValue; | ||
} | ||
} | ||
} |
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