mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
Merge branch 'feat/XmlUtilsRoku' of Common/Utils into ConnectPro_v1.3
This commit is contained in:
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Added Shim to read a list from xml with no root element
|
- Added Shim to read a list from xml with no root element
|
||||||
|
- Added a URI query builder
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Fixed JSON DateTime parsing in .Net Standard
|
- Fixed JSON DateTime parsing in .Net Standard
|
||||||
|
|||||||
@@ -211,6 +211,7 @@
|
|||||||
<Compile Include="Timers\Repeater.cs" />
|
<Compile Include="Timers\Repeater.cs" />
|
||||||
<Compile Include="Timers\SafeTimer.cs" />
|
<Compile Include="Timers\SafeTimer.cs" />
|
||||||
<Compile Include="TryUtils.cs" />
|
<Compile Include="TryUtils.cs" />
|
||||||
|
<Compile Include="UriQueryBuilder.cs" />
|
||||||
<Compile Include="UriUtils.cs" />
|
<Compile Include="UriUtils.cs" />
|
||||||
<Compile Include="Xml\AbstractGenericXmlConverter.cs" />
|
<Compile Include="Xml\AbstractGenericXmlConverter.cs" />
|
||||||
<Compile Include="Xml\AbstractXmlConverter.cs" />
|
<Compile Include="Xml\AbstractXmlConverter.cs" />
|
||||||
|
|||||||
41
ICD.Common.Utils/UriQueryBuilder.cs
Normal file
41
ICD.Common.Utils/UriQueryBuilder.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user