Updates webhook client project to .NET 6.0 (#1777)

* Included globalusing file for webhookclient

* Included file scope namespaces for Webhookclient

* Updated packages in WebHookClient project
This commit is contained in:
Sumit Ghosh 2021-10-25 18:35:03 +05:30 committed by GitHub
parent f5c1af1535
commit 0823cb977d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 308 additions and 364 deletions

View File

@ -1,13 +1,5 @@
using Microsoft.AspNetCore.Authentication; namespace WebhookClient.Controllers;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
using System.Threading.Tasks;
namespace WebhookClient.Controllers
{
[Authorize] [Authorize]
public class AccountController : Controller public class AccountController : Controller
{ {
@ -34,4 +26,3 @@ namespace WebhookClient.Controllers
new AuthenticationProperties { RedirectUri = homeUrl }); new AuthenticationProperties { RedirectUri = homeUrl });
} }
} }
}

View File

@ -1,13 +1,5 @@
using Microsoft.AspNetCore.Mvc; namespace WebhookClient.Controllers;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Linq;
using System.Threading.Tasks;
using WebhookClient.Models;
using WebhookClient.Services;
namespace WebhookClient.Controllers
{
[ApiController] [ApiController]
[Route("webhook-received")] [Route("webhook-received")]
public class WebhooksReceivedController : Controller public class WebhooksReceivedController : Controller
@ -50,4 +42,3 @@ namespace WebhookClient.Controllers
return BadRequest(); return BadRequest();
} }
} }
}

View File

@ -0,0 +1,27 @@
global using Microsoft.AspNetCore.Authentication;
global using Microsoft.AspNetCore.Authentication.Cookies;
global using Microsoft.AspNetCore.Authentication.OpenIdConnect;
global using Microsoft.AspNetCore.Authorization;
global using Microsoft.AspNetCore.Mvc;
global using System.Security.Claims;
global using System.Threading.Tasks;
global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using System.Linq;
global using WebhookClient.Models;
global using WebhookClient.Services;
global using System;
global using System.Collections.Generic;
global using System.Net.Http;
global using System.Text.Json;
global using Microsoft.AspNetCore.Http;
global using System.Net.Http.Headers;
global using System.Threading;
global using Microsoft.AspNetCore;
global using Microsoft.AspNetCore.Hosting;
global using WebhookClient;
global using Microsoft.AspNetCore.Builder;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using System.Net;

View File

@ -1,7 +1,6 @@
namespace WebhookClient namespace WebhookClient;
{
static class HeaderNames static class HeaderNames
{ {
public const string WebHookCheckHeader = "X-eshop-whtoken"; public const string WebHookCheckHeader = "X-eshop-whtoken";
} }
}

View File

@ -1,13 +1,5 @@
using Microsoft.AspNetCore.Authentication; namespace WebhookClient;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
namespace WebhookClient
{
public class HttpClientAuthorizationDelegatingHandler public class HttpClientAuthorizationDelegatingHandler
: DelegatingHandler : DelegatingHandler
{ {
@ -46,4 +38,3 @@ namespace WebhookClient
.GetTokenAsync(ACCESS_TOKEN); .GetTokenAsync(ACCESS_TOKEN);
} }
} }
}

View File

@ -1,7 +1,5 @@
using System; namespace WebhookClient.Models;
namespace WebhookClient.Models
{
public class WebHookReceived public class WebHookReceived
{ {
public DateTime When { get; set; } public DateTime When { get; set; }
@ -10,4 +8,3 @@ namespace WebhookClient.Models
public string Token { get; set; } public string Token { get; set; }
} }
}

View File

@ -1,7 +1,5 @@
using System; namespace WebhookClient.Models;
namespace WebhookClient.Models
{
public class WebhookData public class WebhookData
{ {
public DateTime When { get; set; } public DateTime When { get; set; }
@ -10,4 +8,3 @@ namespace WebhookClient.Models
public string Type { get; set; } public string Type { get; set; }
} }
}

View File

@ -1,11 +1,8 @@
using System; namespace WebhookClient.Models;
namespace WebhookClient.Models
{
public class WebhookResponse public class WebhookResponse
{ {
public DateTime Date { get; set; } public DateTime Date { get; set; }
public string DestUrl { get; set; } public string DestUrl { get; set; }
public string Token { get; set; } public string Token { get; set; }
} }
}

View File

@ -1,5 +1,5 @@
namespace WebhookClient.Models namespace WebhookClient.Models;
{
public class WebhookSubscriptionRequest public class WebhookSubscriptionRequest
{ {
public string Url { get; set; } public string Url { get; set; }
@ -7,4 +7,3 @@
public string Event { get; set; } public string Event { get; set; }
public string GrantUrl { get; set; } public string GrantUrl { get; set; }
} }
}

View File

@ -1,8 +1,4 @@
using Microsoft.AspNetCore; CreateWebHostBuilder(args).Build().Run();
using Microsoft.AspNetCore.Hosting;
using WebhookClient;
CreateWebHostBuilder(args).Build().Run();
IWebHostBuilder CreateWebHostBuilder(string[] args) => IWebHostBuilder CreateWebHostBuilder(string[] args) =>

View File

@ -1,12 +1,7 @@
using System.Collections.Generic; namespace WebhookClient.Services;
using System.Threading.Tasks;
using WebhookClient.Models;
namespace WebhookClient.Services
{
public interface IHooksRepository public interface IHooksRepository
{ {
Task<IEnumerable<WebHookReceived>> GetAll(); Task<IEnumerable<WebHookReceived>> GetAll();
Task AddNew(WebHookReceived hook); Task AddNew(WebHookReceived hook);
} }
}

View File

@ -1,11 +1,6 @@
using System.Collections.Generic; namespace WebhookClient.Services;
using System.Threading.Tasks;
using WebhookClient.Models;
namespace WebhookClient.Services
{
public interface IWebhooksClient public interface IWebhooksClient
{ {
Task<IEnumerable<WebhookResponse>> LoadWebhooks(); Task<IEnumerable<WebhookResponse>> LoadWebhooks();
} }
}

View File

@ -1,10 +1,5 @@
using System.Collections.Generic; namespace WebhookClient.Services;
using System.Linq;
using System.Threading.Tasks;
using WebhookClient.Models;
namespace WebhookClient.Services
{
public class InMemoryHooksRepository : IHooksRepository public class InMemoryHooksRepository : IHooksRepository
{ {
private readonly List<WebHookReceived> _data; private readonly List<WebHookReceived> _data;
@ -22,4 +17,3 @@ namespace WebhookClient.Services
return Task.FromResult(_data.AsEnumerable()); return Task.FromResult(_data.AsEnumerable());
} }
} }
}

View File

@ -1,12 +1,5 @@
using Microsoft.Extensions.Options; namespace WebhookClient.Services;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using WebhookClient.Models;
using System.Text.Json;
namespace WebhookClient.Services
{
public class WebhooksClient : IWebhooksClient public class WebhooksClient : IWebhooksClient
{ {
@ -29,4 +22,3 @@ namespace WebhookClient.Services
return subscriptions; return subscriptions;
} }
} }
}

View File

@ -1,5 +1,5 @@
namespace WebhookClient namespace WebhookClient;
{
public class Settings public class Settings
{ {
public string Token { get; set; } public string Token { get; set; }
@ -11,4 +11,3 @@
public bool ValidateToken { get; set; } public bool ValidateToken { get; set; }
} }
}

View File

@ -1,20 +1,5 @@
using Microsoft.AspNetCore.Authentication.Cookies; namespace WebhookClient;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Linq;
using System.Net;
using System.Threading;
using WebhookClient.Services;
namespace WebhookClient
{
public class Startup public class Startup
{ {
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
@ -162,4 +147,3 @@ namespace WebhookClient
return services; return services;
} }
} }
}

View File

@ -13,9 +13,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" /> <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0-preview.7.21378.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.1" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0-preview.7.21413.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>