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
@{ | |
ViewData["Title"] = "Home Page"; | |
} | |
<div class="text-center"> | |
<h1 class="display-4">Welcome</h1> | |
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> | |
<p>We have injected Pet Store to our DI and retrieved data from API.</p> | |
<ul> |
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
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
namespace Samples.AspNetCoreMvc.ClientInjectedToStartup.PetStore | |
{ | |
/// <summary>This partial class allows to wrap and extend the generated client logic if you need that.</summary> | |
public partial class Client : IPetStoreClient | |
{ | |
// Note: let's implement the interface methods we want to expose |
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
public void ConfigureServices(IServiceCollection services) | |
{ | |
... | |
// Inject generated PetStore client via using HttpClientFactory to implement resilient HTTP requests. | |
services.AddHttpClient<IPetStoreClient, Client>((provider, client) => | |
{ | |
client.BaseAddress = new System.Uri("https://petstore.swagger.io/v2/"); | |
}); | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); |
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
public class HomeController : Controller | |
{ | |
private readonly IPetStoreClient _petStoreClient; | |
public HomeController(IPetStoreClient petStoreClient) | |
{ | |
_petStoreClient = petStoreClient; | |
} | |
public async Task<IActionResult> Index() |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Xunit; | |
using Xunit.Abstractions; | |
namespace ListToTree | |
{ | |
public class Category | |
{ |