Refactor YAML parsing logic and settings handling across Client and Server projects, improve request building in the client.
This commit is contained in:
@@ -5,6 +5,6 @@ namespace VirtualDDNSRouter.Server.Context;
|
||||
|
||||
[YamlStaticContext]
|
||||
[YamlSerializable(typeof(Rule))]
|
||||
public partial class YamlStaticContext : StaticContext
|
||||
public partial class YamlStaticContextServer : StaticContext
|
||||
{
|
||||
}
|
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using VirtualDDNSRouter.Server.Context;
|
||||
using VirtualDDNSRouter.Server.Interfaces;
|
||||
using VirtualDDNSRouter.Server.Models;
|
||||
@@ -19,7 +18,7 @@ public class YamlParser : IYamlParser
|
||||
var yamlContent = await File.ReadAllTextAsync(_yamlFilePath).ConfigureAwait(false);
|
||||
|
||||
// Build the deserializer with explicit naming convention
|
||||
var deserializer = new StaticDeserializerBuilder(new YamlStaticContext())
|
||||
var deserializer = new StaticDeserializerBuilder(new YamlStaticContextServer())
|
||||
.WithNamingConvention(UnderscoredNamingConvention.Instance) // maps api_key -> apiKey
|
||||
.IgnoreUnmatchedProperties()
|
||||
.Build();
|
||||
@@ -27,6 +26,6 @@ public class YamlParser : IYamlParser
|
||||
// Deserialize into a list of Rule
|
||||
var rules = deserializer.Deserialize<List<Rule>>(yamlContent);
|
||||
|
||||
return rules ?? new List<Rule>();
|
||||
return rules;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user