mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-18 05:47:43 +01:00
galaxy brain 2: bit of restructure (Bootstrap)
This commit is contained in:
parent
2438a89867
commit
350d2961c1
19 changed files with 345 additions and 136 deletions
55
Dalamud.Bootstrap/SqexArg/ArgumentBuilder.cs
Normal file
55
Dalamud.Bootstrap/SqexArg/ArgumentBuilder.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Dalamud.Bootstrap.SqexArg
|
||||
{
|
||||
internal sealed class ArgumentBuilder
|
||||
{
|
||||
private readonly Dictionary<string, string> m_dict;
|
||||
|
||||
public ArgumentBuilder()
|
||||
{
|
||||
m_dict = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public ArgumentBuilder Add(string key, string value)
|
||||
{
|
||||
m_dict.Add(key, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ArgumentBuilder Clear()
|
||||
{
|
||||
m_dict.Clear();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private static void Write(StringBuilder buffer, string key, string value)
|
||||
{
|
||||
var escapedKey = EscapeValue(key);
|
||||
var escapedvalue = EscapeValue(value);
|
||||
|
||||
buffer.Append($" /{escapedKey} ={escapedvalue}");
|
||||
}
|
||||
|
||||
private static string EscapeValue(string value)
|
||||
{
|
||||
// a single space character is represented as dobule spaces
|
||||
return value.Replace(" ", " ");
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var buffer = new StringBuilder(256);
|
||||
|
||||
foreach (var kv in m_dict)
|
||||
{
|
||||
Write(buffer, kv.Key, kv.Value);
|
||||
}
|
||||
|
||||
return buffer.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue