-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple "REST" access to the IniConfig, this can be used toget…
…her with a HttpListener or a customer url to modify a configuration. (experimental)
- Loading branch information
1 parent
979ec28
commit 1701388
Showing
5 changed files
with
173 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Web; | ||
|
||
namespace Dapplo.Config.Support | ||
{ | ||
public static class UriExtensions | ||
{ | ||
/// <summary> | ||
/// Create a NameValueCollection from the query part of the uri | ||
/// </summary> | ||
/// <param name="uri"></param> | ||
/// <returns>NameValueCollection</returns> | ||
public static NameValueCollection QueryToNameValues(this Uri uri) | ||
{ | ||
if (!string.IsNullOrEmpty(uri.Query)) | ||
{ | ||
return HttpUtility.ParseQueryString(uri.Query); | ||
} | ||
return new NameValueCollection(); | ||
} | ||
|
||
/// <summary> | ||
/// Create a IDictionary string,string from the query part of the uri | ||
/// </summary> | ||
/// <param name="uri"></param> | ||
/// <returns>IDictionary string,string</returns> | ||
public static IDictionary<string, string> QueryToDictionary(this Uri uri) | ||
{ | ||
var returnValue = new Dictionary<string, string>(); | ||
var nameValues = uri.QueryToNameValues(); | ||
for(int i=0; i<nameValues.Count; i++) { | ||
var value = nameValues[i]; | ||
var key = nameValues.AllKeys[i]; | ||
if (returnValue.ContainsKey(key)) | ||
{ | ||
returnValue[key] = value; | ||
} | ||
else | ||
{ | ||
returnValue.Add(key, value); | ||
} | ||
} | ||
return returnValue; | ||
} | ||
} | ||
} |