Merge branch 'feat/XmlUtilsRoku' of Common/Utils into ConnectPro_v1.3

This commit is contained in:
Chris Cameron
2019-06-04 17:17:33 +00:00
committed by Gogs
3 changed files with 43 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Added Shim to read a list from xml with no root element
- Added a URI query builder
### Changed
- Fixed JSON DateTime parsing in .Net Standard

View File

@@ -211,6 +211,7 @@
<Compile Include="Timers\Repeater.cs" />
<Compile Include="Timers\SafeTimer.cs" />
<Compile Include="TryUtils.cs" />
<Compile Include="UriQueryBuilder.cs" />
<Compile Include="UriUtils.cs" />
<Compile Include="Xml\AbstractGenericXmlConverter.cs" />
<Compile Include="Xml\AbstractXmlConverter.cs" />

View File

@@ -0,0 +1,41 @@
using System.Collections.Generic;
using System.Text;
namespace ICD.Common.Utils
{
public sealed class UriQueryBuilder
{
private readonly Dictionary<string, string> m_Parameters;
public UriQueryBuilder()
{
m_Parameters = new Dictionary<string, string>();
}
public UriQueryBuilder Append(string key, string value)
{
m_Parameters.Add(key, value);
return this;
}
public override string ToString()
{
StringBuilder builder = new StringBuilder("?");
bool first = true;
foreach (KeyValuePair<string, string> kvp in m_Parameters)
{
if (!first)
builder.Append('&');
first = false;
builder.Append(kvp.Key);
builder.Append('=');
builder.Append(kvp.Value);
}
return builder.ToString();
}
}
}