chore: renamed parameter names for ISerializer methods
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Engine.Core.Config;
|
||||
|
||||
namespace Engine.Serializers.Yaml;
|
||||
|
||||
public class YamlConfiguration : BasicConfiguration
|
||||
{
|
||||
public readonly string FilePath;
|
||||
|
||||
private readonly YamlSerializer yamlSerializer = new();
|
||||
|
||||
public YamlConfiguration(string filePath)
|
||||
{
|
||||
if (!filePath.EndsWith(".yaml"))
|
||||
filePath += ".yaml";
|
||||
|
||||
FilePath = filePath;
|
||||
|
||||
bool isRelativePath = Path.GetFullPath(filePath).CompareTo(filePath) != 0;
|
||||
|
||||
if (isRelativePath)
|
||||
FilePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath));
|
||||
|
||||
if (Path.GetDirectoryName(FilePath) is string directoryPath)
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
|
||||
if (!File.Exists(FilePath))
|
||||
return;
|
||||
|
||||
string yamlFileText = File.ReadAllText(FilePath);
|
||||
Dictionary<string, string> valuePairs = yamlSerializer.Deserialize<Dictionary<string, string>>(yamlFileText);
|
||||
|
||||
foreach ((string key, string value) in valuePairs)
|
||||
Set(key, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user