Skip to content

Commit d2a63af

Browse files
committed
code refactor
1 parent a1a816f commit d2a63af

14 files changed

+114
-99
lines changed

src/Api/Endpoints/V1/Products/Create.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Xero.Demo.Api.Domain;
88
using Xero.Demo.Api.Domain.Extension;
99
using Xero.Demo.Api.Domain.Models;
10-
using Xero.Demo.Api.Xero.Demo.Domain.Models;
1110
using static Xero.Demo.Api.Domain.Models.CONSTANTS;
1211

1312
namespace Xero.Demo.Api.Endpoints.V1.Products

src/Api/Product.db

0 Bytes
Binary file not shown.

src/Api/Xero.Demo.Infrastructure/Extensions/UseMiddleWareExtension.cs

Lines changed: 0 additions & 98 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.AspNetCore.Localization;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text.RegularExpressions;
7+
using System.Threading.Tasks;
8+
9+
namespace Xero.Demo.Api.Xero.Demo.Infrastructure.Languages
10+
{
11+
public class JsonRequestCultureProvider : RequestCultureProvider
12+
{
13+
private static readonly Regex LocalePattern = new Regex(@"^[a-z]{2}(-[a-z]{2,4})?$", RegexOptions.IgnoreCase);
14+
15+
public override Task<ProviderCultureResult> DetermineProviderCultureResult(HttpContext httpContext)
16+
{
17+
if (httpContext == null) throw new ArgumentNullException(nameof(httpContext));
18+
19+
var parts = httpContext.Request.Path.Value.Split('/');
20+
if (parts.Length < 3) return Task.FromResult<ProviderCultureResult>(null);
21+
22+
if (!LocalePattern.IsMatch(parts[2])) return Task.FromResult<ProviderCultureResult>(null);
23+
24+
var culture = parts[2];
25+
26+
culture = culture ?? "en-US";
27+
28+
return Task.FromResult(new ProviderCultureResult(culture));
29+
}
30+
}
31+
}

src/Api/Xero.Demo.Infrastructure/Extensions/AddAuthorizationExtension.cs renamed to src/Api/Xero.Demo.Infrastructure/Setup/AddAuthorizationExtension.cs

File renamed without changes.

src/Api/Xero.Demo.Infrastructure/Extensions/AddLocalizationExtension.cs renamed to src/Api/Xero.Demo.Infrastructure/Setup/AddLocalizationExtension.cs

File renamed without changes.

src/Api/Xero.Demo.Infrastructure/Extensions/AddMiddleWareExtensions.cs renamed to src/Api/Xero.Demo.Infrastructure/Setup/AddMiddleWareExtensions.cs

File renamed without changes.

src/Api/Xero.Demo.Infrastructure/Extensions/ErrorExtensions.cs renamed to src/Api/Xero.Demo.Infrastructure/Setup/ErrorExtensions.cs

File renamed without changes.

src/Api/Xero.Demo.Infrastructure/Extensions/JwtMiddleware.cs renamed to src/Api/Xero.Demo.Infrastructure/Setup/JwtMiddleware.cs

File renamed without changes.

src/Api/Xero.Demo.Infrastructure/Extensions/RequestResponseLoggingMiddleware.cs renamed to src/Api/Xero.Demo.Infrastructure/Setup/RequestResponseLoggingMiddleware.cs

File renamed without changes.

0 commit comments

Comments
 (0)