From dc824b2034eb743c7cc8bcea10625a9812dc4792 Mon Sep 17 00:00:00 2001 From: Austin Noska Date: Tue, 4 Jun 2019 12:19:12 -0400 Subject: [PATCH 1/2] feat: Added a URI query builder --- .../ICD.Common.Utils_SimplSharp.csproj | 1 + ICD.Common.Utils/UriQueryBuilder.cs | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 ICD.Common.Utils/UriQueryBuilder.cs diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj index 23c1b99..7939358 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj @@ -211,6 +211,7 @@ + diff --git a/ICD.Common.Utils/UriQueryBuilder.cs b/ICD.Common.Utils/UriQueryBuilder.cs new file mode 100644 index 0000000..7b66485 --- /dev/null +++ b/ICD.Common.Utils/UriQueryBuilder.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.Text; + +namespace ICD.Common.Utils +{ + public sealed class UriQueryBuilder + { + private readonly Dictionary m_Parameters; + + public UriQueryBuilder() + { + m_Parameters = new Dictionary(); + } + + 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 kvp in m_Parameters) + { + if (!first) + builder.Append('&'); + first = false; + + builder.Append(kvp.Key); + builder.Append('='); + builder.Append(kvp.Value); + } + + return builder.ToString(); + } + } +} \ No newline at end of file From 536742a1c626613b4f7e16cd47f55e15c8cfa401 Mon Sep 17 00:00:00 2001 From: Austin Noska Date: Tue, 4 Jun 2019 12:54:39 -0400 Subject: [PATCH 2/2] docs: updating changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18366b9..e99f693 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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