-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use file scoped namespaces in Handyman.AspNetCore
- Loading branch information
1 parent
d4ecc7c
commit bace320
Showing
45 changed files
with
903 additions
and
944 deletions.
There are no files selected for viewing
13 changes: 6 additions & 7 deletions
13
src/Handyman.AspNetCore/src/ApiVersioning/Abstractions/ApiVersionDescriptor.cs
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
namespace Handyman.AspNetCore.ApiVersioning.Abstractions | ||
namespace Handyman.AspNetCore.ApiVersioning.Abstractions; | ||
|
||
internal class ApiVersionDescriptor | ||
{ | ||
internal class ApiVersionDescriptor | ||
{ | ||
public IApiVersion[] Versions { get; set; } | ||
public bool IsOptional { get; set; } | ||
public IApiVersion DefaultVersion { get; set; } | ||
} | ||
public IApiVersion[] Versions { get; set; } | ||
public bool IsOptional { get; set; } | ||
public IApiVersion DefaultVersion { get; set; } | ||
} |
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
9 changes: 4 additions & 5 deletions
9
src/Handyman.AspNetCore/src/ApiVersioning/ApiVersionFeature.cs
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace Handyman.AspNetCore.ApiVersioning | ||
namespace Handyman.AspNetCore.ApiVersioning; | ||
|
||
internal class ApiVersionFeature | ||
{ | ||
internal class ApiVersionFeature | ||
{ | ||
internal string MatchedVersion { get; set; } | ||
} | ||
internal string MatchedVersion { get; set; } | ||
} |
9 changes: 4 additions & 5 deletions
9
src/Handyman.AspNetCore/src/ApiVersioning/ApiVersionOptions.cs
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace Handyman.AspNetCore.ApiVersioning | ||
namespace Handyman.AspNetCore.ApiVersioning; | ||
|
||
public class ApiVersionOptions | ||
{ | ||
public class ApiVersionOptions | ||
{ | ||
public int InvalidApiVersionStatusCode { get; set; } | ||
} | ||
public int InvalidApiVersionStatusCode { get; set; } | ||
} |
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
namespace Handyman.AspNetCore.ApiVersioning | ||
namespace Handyman.AspNetCore.ApiVersioning; | ||
|
||
public interface IApiVersion | ||
{ | ||
public interface IApiVersion | ||
{ | ||
string Text { get; } | ||
string Text { get; } | ||
|
||
bool IsMatch(IApiVersion other); | ||
} | ||
bool IsMatch(IApiVersion other); | ||
} |
9 changes: 4 additions & 5 deletions
9
src/Handyman.AspNetCore/src/ApiVersioning/IApiVersionParser.cs
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace Handyman.AspNetCore.ApiVersioning | ||
namespace Handyman.AspNetCore.ApiVersioning; | ||
|
||
public interface IApiVersionParser | ||
{ | ||
public interface IApiVersionParser | ||
{ | ||
bool TryParse(string candidate, out IApiVersion version); | ||
} | ||
bool TryParse(string candidate, out IApiVersion version); | ||
} |
9 changes: 4 additions & 5 deletions
9
src/Handyman.AspNetCore/src/ApiVersioning/IApiVersionReader.cs
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.Primitives; | ||
|
||
namespace Handyman.AspNetCore.ApiVersioning | ||
namespace Handyman.AspNetCore.ApiVersioning; | ||
|
||
public interface IApiVersionReader | ||
{ | ||
public interface IApiVersionReader | ||
{ | ||
bool TryRead(HttpRequest httpRequest, out StringValues values); | ||
} | ||
bool TryRead(HttpRequest httpRequest, out StringValues values); | ||
} |
25 changes: 12 additions & 13 deletions
25
...ore/src/ApiVersioning/MajorMinorPreReleaseVersionScheme/MajorMinorPreReleaseApiVersion.cs
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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Handyman.AspNetCore.ApiVersioning.MajorMinorPreReleaseVersionScheme | ||
namespace Handyman.AspNetCore.ApiVersioning.MajorMinorPreReleaseVersionScheme; | ||
|
||
[DebuggerDisplay("major/minor/pre-release: {Text}")] | ||
internal class MajorMinorPreReleaseApiVersion : IApiVersion | ||
{ | ||
[DebuggerDisplay("major/minor/pre-release: {Text}")] | ||
internal class MajorMinorPreReleaseApiVersion : IApiVersion | ||
{ | ||
public string Text { get; } | ||
public string Text { get; } | ||
|
||
internal MajorMinorPreReleaseApiVersion(string version) | ||
{ | ||
Text = version; | ||
} | ||
internal MajorMinorPreReleaseApiVersion(string version) | ||
{ | ||
Text = version; | ||
} | ||
|
||
public bool IsMatch(IApiVersion other) | ||
{ | ||
return other is MajorMinorPreReleaseApiVersion o && Text.Equals(o.Text, StringComparison.OrdinalIgnoreCase); | ||
} | ||
public bool IsMatch(IApiVersion other) | ||
{ | ||
return other is MajorMinorPreReleaseApiVersion o && Text.Equals(o.Text, StringComparison.OrdinalIgnoreCase); | ||
} | ||
} |
25 changes: 12 additions & 13 deletions
25
...c/ApiVersioning/MajorMinorPreReleaseVersionScheme/MajorMinorPreReleaseApiVersionParser.cs
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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Handyman.AspNetCore.ApiVersioning.MajorMinorPreReleaseVersionScheme | ||
namespace Handyman.AspNetCore.ApiVersioning.MajorMinorPreReleaseVersionScheme; | ||
|
||
internal class MajorMinorPreReleaseApiVersionParser : IApiVersionParser | ||
{ | ||
internal class MajorMinorPreReleaseApiVersionParser : IApiVersionParser | ||
{ | ||
private static readonly Regex Regex = new Regex(@"^\d+(\.\d+)?(-[.0-9a-z]+)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); | ||
private static readonly Regex Regex = new Regex(@"^\d+(\.\d+)?(-[.0-9a-z]+)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); | ||
|
||
public bool TryParse(string candidate, out IApiVersion version) | ||
public bool TryParse(string candidate, out IApiVersion version) | ||
{ | ||
if (string.IsNullOrWhiteSpace(candidate) || !Regex.IsMatch(candidate)) | ||
{ | ||
if (string.IsNullOrWhiteSpace(candidate) || !Regex.IsMatch(candidate)) | ||
{ | ||
version = null; | ||
return false; | ||
} | ||
|
||
version = new MajorMinorPreReleaseApiVersion(candidate); | ||
return true; | ||
version = null; | ||
return false; | ||
} | ||
|
||
version = new MajorMinorPreReleaseApiVersion(candidate); | ||
return true; | ||
} | ||
} |
25 changes: 12 additions & 13 deletions
25
src/Handyman.AspNetCore/src/ApiVersioning/ModelBinding/ApiVersionModelBinder.cs
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 |
---|---|---|
@@ -1,20 +1,19 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc.ModelBinding; | ||
using Microsoft.AspNetCore.Mvc.ModelBinding; | ||
using System.Threading.Tasks; | ||
|
||
namespace Handyman.AspNetCore.ApiVersioning.ModelBinding | ||
namespace Handyman.AspNetCore.ApiVersioning.ModelBinding; | ||
|
||
internal class ApiVersionModelBinder : IModelBinder | ||
{ | ||
internal class ApiVersionModelBinder : IModelBinder | ||
public Task BindModelAsync(ModelBindingContext bindingContext) | ||
{ | ||
public Task BindModelAsync(ModelBindingContext bindingContext) | ||
{ | ||
var feature = bindingContext.HttpContext.Features.Get<ApiVersionFeature>(); | ||
|
||
if (feature != null) | ||
{ | ||
bindingContext.Result = ModelBindingResult.Success(feature.MatchedVersion); | ||
} | ||
var feature = bindingContext.HttpContext.Features.Get<ApiVersionFeature>(); | ||
|
||
return Task.CompletedTask; | ||
if (feature != null) | ||
{ | ||
bindingContext.Result = ModelBindingResult.Success(feature.MatchedVersion); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
Oops, something went wrong.