Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc1b82f0ab | ||
|
|
8c036b0986 | ||
|
|
d5caf139e9 | ||
|
|
ccc3f229d0 | ||
|
|
4bf5ed64dc | ||
|
|
59887c06c0 | ||
|
|
1a82f9db70 | ||
|
|
8b66bdcd92 | ||
|
|
4ce00cf6bb | ||
|
|
edfb21960a | ||
|
|
4db92f4965 | ||
|
|
65b437f5f3 | ||
|
|
a75d4fab2a | ||
|
|
63c25a8c6e | ||
|
|
87e9cb4b85 | ||
|
|
fa1e78cb24 | ||
|
|
ad7ff272a6 | ||
|
|
58f03ea1af | ||
|
|
00f8f60971 | ||
|
|
84742e8f47 | ||
|
|
bb75e3006e | ||
|
|
68956cded5 | ||
|
|
ec67f8ad1d | ||
|
|
2011b935d9 | ||
|
|
526f7b04c8 | ||
|
|
9dc6c4a466 |
23
.vscode/launch.json
vendored
23
.vscode/launch.json
vendored
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": ".NET Core Launch (console)",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "build",
|
|
||||||
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"externalConsole": false,
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": ".NET Core Attach",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "attach",
|
|
||||||
"processId": "${command.pickProcess}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
16
.vscode/tasks.json
vendored
16
.vscode/tasks.json
vendored
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.1.0",
|
|
||||||
"command": "dotnet",
|
|
||||||
"isShellCommand": true,
|
|
||||||
"args": [],
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"taskName": "build",
|
|
||||||
"args": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"isBuildCommand": true,
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -3,9 +3,9 @@ if($env:APPVEYOR_REPO_TAG -eq "true")
|
|||||||
"do not publish coverall data on tag builds"
|
"do not publish coverall data on tag builds"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nuget install OpenCover -Version 4.6.519 -OutputDirectory tools
|
nuget install OpenCover -Source https://api.nuget.org/v3/index.json -Version 4.6.519 -OutputDirectory tools
|
||||||
nuget install coveralls.net -Version 0.7.0 -OutputDirectory tools
|
nuget install coveralls.net -Source https://api.nuget.org/v3/index.json -Version 0.7.0 -OutputDirectory tools
|
||||||
|
|
||||||
.\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:" test "".\src\UriBuilder.Fluent.UnitTests"" -f net461" -register:user -filter:"+[UriBuilder*]* -[*Tests]*" -returntargetcode -output:opencover_results.xml
|
.\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe -oldStyle -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:" test "".\src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.csproj"" -f net461 --no-build" -register:user -filter:"+[UriBuilder*]* -[*Tests]*" -returntargetcode -output:opencover_results.xml
|
||||||
|
|
||||||
.\tools\coveralls.net.0.7.0\tools\csmacnz.Coveralls.exe --opencover -i .\opencover_results.xml
|
.\tools\coveralls.net.0.7.0\tools\csmacnz.Coveralls.exe --opencover -i .\opencover_results.xml
|
||||||
@@ -19,6 +19,7 @@ new UriBuilder()
|
|||||||
.WithHost("awesome.com")
|
.WithHost("awesome.com")
|
||||||
.WithPathSegment("seg")
|
.WithPathSegment("seg")
|
||||||
.UseHttps()
|
.UseHttps()
|
||||||
|
.Uri
|
||||||
.ToString()
|
.ToString()
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -30,6 +31,7 @@ or
|
|||||||
|
|
||||||
new UriBuilder("https://awesome.com/yo)
|
new UriBuilder("https://awesome.com/yo)
|
||||||
.WithParameter("id", "5")
|
.WithParameter("id", "5")
|
||||||
|
.Uri
|
||||||
.ToString();
|
.ToString();
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -78,4 +80,4 @@ var uri = new UriBuilder("https://awesome.com")
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
result: `http%3A%2F%2Fawesome.com%2F%3Fyo%3Ddawg%3C`
|
result: `http%3A%2F%2Fawesome.com%2F%3Fyo%3Ddawg%3C`
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 15.0.26430.14
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B4EB6F69-0F56-4875-95AD-E4DEB5D18A74}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B4EB6F69-0F56-4875-95AD-E4DEB5D18A74}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AC680F4D-C1B2-4F06-8464-CC987B1F0008}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AC680F4D-C1B2-4F06-8464-CC987B1F0008}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
appveyor.yml = appveyor.yml
|
appveyor.yml = appveyor.yml
|
||||||
global.json = global.json
|
|
||||||
Readme.md = Readme.md
|
Readme.md = Readme.md
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UriBuilder.Fluent", "src\UriBuilder.Fluent\UriBuilder.Fluent.xproj", "{B8458F59-DEBD-4844-AA29-EE3B4388AA7A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UriBuilder.Fluent", "src\UriBuilder.Fluent\UriBuilder.Fluent.csproj", "{B8458F59-DEBD-4844-AA29-EE3B4388AA7A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UriBuilder.Fluent.UnitTests", "src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.xproj", "{F421A9EE-180C-413E-A0CD-665295825646}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UriBuilder.Fluent.UnitTests", "src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.csproj", "{F421A9EE-180C-413E-A0CD-665295825646}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
28
appveyor.yml
28
appveyor.yml
@@ -1,34 +1,28 @@
|
|||||||
|
image: Visual Studio 2017
|
||||||
configuration: Release
|
configuration: Release
|
||||||
version: 1.0.{build}
|
version: 1.0.{build}
|
||||||
nuget:
|
|
||||||
account_feed: true
|
|
||||||
project_feed: true
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: 'src\**\*.nupkg'
|
- path: output\**.nupkg
|
||||||
|
|
||||||
init:
|
init:
|
||||||
- git config --global core.autocrlf true
|
- git config --global core.autocrlf true
|
||||||
|
|
||||||
before_build:
|
|
||||||
- ps: invoke-webrequest https://go.microsoft.com/fwlink/?LinkID=827524 -OutFile core.exe
|
|
||||||
- ps: .\core.exe /install /quiet /norestart
|
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- ps: dotnet restore
|
- ps: >-
|
||||||
- ps: dotnet build -c Release .\src\UriBuilder.Fluent
|
dotnet restore UriBuilder.Fluent.sln --source https://api.nuget.org/v3/index.json
|
||||||
- ps: dotnet build -c Release .\src\UriBuilder.Fluent.UnitTests
|
dotnet build UriBuilder.Fluent.sln --configuration Release
|
||||||
|
if($env:APPVEYOR_REPO_TAG -eq "true")
|
||||||
|
{
|
||||||
|
dotnet pack src\UriBuilder.Fluent\UriBuilder.Fluent.csproj --configuration Release --output ..\..\output /p:Version=$env:APPVEYOR_REPO_TAG_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- ps: dotnet test -c Release .\src\UriBuilder.Fluent.UnitTests
|
- ps: dotnet test -c Release .\src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.csproj
|
||||||
- ps: .\Coverage.ps1
|
|
||||||
- ps: .\update-projectjson.ps1
|
|
||||||
- ps: dotnet restore
|
|
||||||
- ps: dotnet pack -c Release .\src\UriBuilder.Fluent
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
- provider: NuGet
|
- provider: NuGet
|
||||||
api_key:
|
api_key:
|
||||||
secure: QuVcKEvDkLsmdemVpoGBXiTymN46CzvczrDpTHNf1+tTIjOGufptGDmBD9r5LVtn
|
secure: bGn7M6dHOJ3QjwYIv7e34tcY/n9cCUZmL1MnM6jRfmnJOOfwlrS+cdRj2n8Wf31n
|
||||||
on:
|
on:
|
||||||
appveyor_repo_tag: true
|
appveyor_repo_tag: true
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"projects": [ "src", "test" ],
|
|
||||||
"sdk": {
|
|
||||||
"version": "1.0.0-preview2-003131"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -71,6 +71,22 @@ namespace FluentUriBuilder.Tests
|
|||||||
Assert.Equal("http://awesome.com/?awesome", url.Uri.ToString());
|
Assert.Equal("http://awesome.com/?awesome", url.Uri.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestAddFragmentArrayint()
|
||||||
|
{
|
||||||
|
var url = new UriBuilder("http://awesome.com")
|
||||||
|
.WithFragment("awesome", new List<int>() { 1, 2 }.Cast<object>());
|
||||||
|
Assert.Equal("http://awesome.com/#awesome=1,2", url.Uri.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestAddFragmentNoValue()
|
||||||
|
{
|
||||||
|
var url = new UriBuilder("http://awesome.com")
|
||||||
|
.WithFragment("awesome");
|
||||||
|
Assert.Equal("http://awesome.com/#awesome", url.Uri.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void WithPort()
|
public void WithPort()
|
||||||
{
|
{
|
||||||
@@ -78,6 +94,22 @@ namespace FluentUriBuilder.Tests
|
|||||||
Assert.Equal(url.Port, 22);
|
Assert.Equal(url.Port, 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WithoutDefaultPort()
|
||||||
|
{
|
||||||
|
var url = new UriBuilder("http://awesome.com:80")
|
||||||
|
.WithoutDefaultPort();
|
||||||
|
Assert.Equal("http://awesome.com/", url.Uri.ToString());
|
||||||
|
|
||||||
|
url = new UriBuilder("http://awesome.com:443")
|
||||||
|
.WithoutDefaultPort();
|
||||||
|
Assert.Equal("http://awesome.com:443/", url.Uri.ToString());
|
||||||
|
|
||||||
|
url = new UriBuilder("https://awesome.com:443")
|
||||||
|
.WithoutDefaultPort();
|
||||||
|
Assert.Equal("https://awesome.com/", url.Uri.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void WithHttps()
|
public void WithHttps()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ using System.Runtime.InteropServices;
|
|||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("UriBuilder.Fluent.UnitTests")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
// to COM components. If you need to access a type in this assembly from
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
|||||||
@@ -13,10 +13,12 @@ namespace FluentUriBuilder.Tests
|
|||||||
{
|
{
|
||||||
var tstObj = new UriBuilder();
|
var tstObj = new UriBuilder();
|
||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithParameter(string.Empty, string.Empty));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithParameter(string.Empty, string.Empty));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithFragment(string.Empty, string.Empty));
|
||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithPathSegment(null));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithPathSegment(null));
|
||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithScheme(null));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithScheme(null));
|
||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithHost(null));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithHost(null));
|
||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithParameter(parameterDictionary: null));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithParameter(parameterDictionary: null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithFragment(fragmentDictionary: null));
|
||||||
Assert.Throws<ArgumentOutOfRangeException>(() => tstObj.WithPort(-1));
|
Assert.Throws<ArgumentOutOfRangeException>(() => tstObj.WithPort(-1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
||||||
|
<PackageReference Include="xunit" Version="2.2.0" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UriBuilder.Fluent\UriBuilder.Fluent.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>f421a9ee-180c-413e-a0cd-665295825646</ProjectGuid>
|
|
||||||
<RootNamespace>UriBuilder.Fluent.UnitTests</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ActiveDebugProfile>Start</ActiveDebugProfile>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "1.0.0-*",
|
|
||||||
"testRunner": "xunit",
|
|
||||||
|
|
||||||
"dependencies": {
|
|
||||||
"xunit": "2.2.0-beta2-build3300",
|
|
||||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
|
||||||
"UriBuilder.Fluent": "1.0.0-*"
|
|
||||||
},
|
|
||||||
|
|
||||||
"frameworks": {
|
|
||||||
"net461":{},
|
|
||||||
"netcoreapp1.0": {
|
|
||||||
"dependencies": {
|
|
||||||
"Microsoft.NETCore.App": {
|
|
||||||
"type": "platform",
|
|
||||||
"version": "1.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,10 +5,6 @@ using System.Runtime.InteropServices;
|
|||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("UriBuilder.Fluent")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
// to COM components. If you need to access a type in this assembly from
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
|||||||
@@ -52,18 +52,55 @@ namespace System
|
|||||||
valuesEnum = new string[0];
|
valuesEnum = new string[0];
|
||||||
}
|
}
|
||||||
var intitialValue = string.IsNullOrWhiteSpace(bld.Query) ? "" : $"{bld.Query.TrimStart('?')}&";
|
var intitialValue = string.IsNullOrWhiteSpace(bld.Query) ? "" : $"{bld.Query.TrimStart('?')}&";
|
||||||
var sb = new StringBuilder($"{intitialValue}{key}");
|
bld.Query = intitialValue.AppendKeyValue(key, valuesEnum);
|
||||||
var validValueHit = false;
|
return bld;
|
||||||
foreach(var value in valuesEnum)
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appends a fragments parameter with a key, and many values. Multiple values will be comma seperated. If only 1 value is passed and its null or value, the key will be added to the fragment.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bld"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="values"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static UriBuilder WithFragment(this UriBuilder bld, string key, params string[] values) => bld.WithFragment(key, valuesEnum: values);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appends fragments from dictionary
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bld"></param>
|
||||||
|
/// <param name="fragmentDictionary"></param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static UriBuilder WithFragment(this UriBuilder bld, IDictionary<string, string> fragmentDictionary)
|
||||||
|
{
|
||||||
|
if(fragmentDictionary == null) throw new ArgumentNullException(nameof(fragmentDictionary));
|
||||||
|
foreach(var item in fragmentDictionary)
|
||||||
{
|
{
|
||||||
var toSValue = value?.ToString();
|
bld.WithFragment(item.Key, item.Value);
|
||||||
if(string.IsNullOrWhiteSpace(toSValue)) continue;
|
|
||||||
// we can't just have an = sign since its valid to have query string paramters with no value;
|
|
||||||
if(!validValueHit) toSValue = "=" + value;
|
|
||||||
validValueHit = true;
|
|
||||||
sb.Append($"{toSValue},");
|
|
||||||
}
|
}
|
||||||
bld.Query = sb.ToString().TrimEnd(',');
|
return bld;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appends a fragments with a key, and many values. Multiple values will be comma seperated. If only 1 value is passed and its null or value, the key will be added to the fragment.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bld"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="valuesEnum"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static UriBuilder WithFragment(this UriBuilder bld, string key, IEnumerable<object> valuesEnum)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(key))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
}
|
||||||
|
if(valuesEnum == null)
|
||||||
|
{
|
||||||
|
valuesEnum = new string[0];
|
||||||
|
}
|
||||||
|
var intitialValue = string.IsNullOrWhiteSpace(bld.Fragment) ? "" : $"{bld.Fragment.TrimStart('?')}&";
|
||||||
|
bld.Fragment = intitialValue.AppendKeyValue(key, valuesEnum);
|
||||||
return bld;
|
return bld;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +118,17 @@ namespace System
|
|||||||
return bld;
|
return bld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the port number for default ports
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bld"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static UriBuilder WithoutDefaultPort(this UriBuilder bld)
|
||||||
|
{
|
||||||
|
if (bld.Uri.IsDefaultPort) bld.Port = -1;
|
||||||
|
return bld;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// appends a path segment to the path. Can be called multiple times to append multiple segments
|
/// appends a path segment to the path. Can be called multiple times to append multiple segments
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -155,5 +203,23 @@ namespace System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string ToEscapeDataString(this UriBuilder bld) => Uri.EscapeDataString(bld.Uri.ToString());
|
public static string ToEscapeDataString(this UriBuilder bld) => Uri.EscapeDataString(bld.Uri.ToString());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appends x-www-form-urlencoded key and valuesEnum into initialValue.
|
||||||
|
/// </summary>
|
||||||
|
private static string AppendKeyValue(this string intitialValue, string key, IEnumerable<object> valuesEnum)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder($"{intitialValue}{key}");
|
||||||
|
var validValueHit = false;
|
||||||
|
foreach(var value in valuesEnum)
|
||||||
|
{
|
||||||
|
var toSValue = value?.ToString();
|
||||||
|
if(string.IsNullOrWhiteSpace(toSValue)) continue;
|
||||||
|
// we can't just have an = sign since its valid to have query string paramters with no value;
|
||||||
|
if(!validValueHit) toSValue = "=" + value;
|
||||||
|
validValueHit = true;
|
||||||
|
sb.Append($"{toSValue},");
|
||||||
|
}
|
||||||
|
return sb.ToString().TrimEnd(',');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
22
src/UriBuilder.Fluent/UriBuilder.Fluent.csproj
Normal file
22
src/UriBuilder.Fluent/UriBuilder.Fluent.csproj
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Authors>Tommy Parnell</Authors>
|
||||||
|
<TargetFrameworks>netstandard1.1;net40;net45</TargetFrameworks>
|
||||||
|
<AssemblyName>UriBuilder.Fluent</AssemblyName>
|
||||||
|
<PackageId>UriBuilder.Fluent</PackageId>
|
||||||
|
<PackageTags>Url building;Uri;Uri building;fluent;extension</PackageTags>
|
||||||
|
<PackageProjectUrl>https://github.com/TerribleDev/UriBuilder.Fluent</PackageProjectUrl>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>b8458f59-debd-4844-aa29-ee3b4388aa7a</ProjectGuid>
|
|
||||||
<RootNamespace>UriBuilder.Fluent</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ActiveDebugProfile>Start</ActiveDebugProfile>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "1.0.0-*",
|
|
||||||
"packOptions": {
|
|
||||||
"owners": [
|
|
||||||
"Tommy Parnell"
|
|
||||||
],
|
|
||||||
"projectUrl": "https://github.com/TerribleDev/UriBuilder.Fluent",
|
|
||||||
"summary": "Fluent extensions for UriBuilder",
|
|
||||||
"tags": [
|
|
||||||
"Url building",
|
|
||||||
"Uri",
|
|
||||||
"Uri building",
|
|
||||||
"fluent",
|
|
||||||
"extension"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"authors": [
|
|
||||||
"Tommy Parnell"
|
|
||||||
],
|
|
||||||
"frameworks": {
|
|
||||||
"netstandard1.1": {
|
|
||||||
"imports": "dnxcore50",
|
|
||||||
"dependencies": {
|
|
||||||
"NETStandard.Library": "1.6.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"net40": {
|
|
||||||
"imports": "dnxcore50"
|
|
||||||
},
|
|
||||||
"net45":{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
$projectJsonFileLocation = "src/UriBuilder.Fluent/project.json"
|
|
||||||
$newVersion = $env:APPVEYOR_REPO_TAG_NAME
|
|
||||||
if($newVersion -eq $null)
|
|
||||||
{
|
|
||||||
$newVersion = "1.0.0-${env:APPVEYOR_BUILD_NUMBER}"
|
|
||||||
}
|
|
||||||
if($newVersion -eq $null)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "$projectJsonFileLocation will be update with new version '$newVersion'"
|
|
||||||
|
|
||||||
$json = (Get-Content $projectJsonFileLocation -Raw) | ConvertFrom-Json
|
|
||||||
$json.version = $newVersion
|
|
||||||
$json | ConvertTo-Json -depth 100 | Out-File $projectJsonFileLocation
|
|
||||||
Reference in New Issue
Block a user