wwwroot/Resources/form-input-list.jsonwwwroot/Resources/form-input-list.json@code {
private Field[]? fields;
protected override async Task OnInitializedAsync()
{
var json = await Http.GetFromJsonAsync<FormData>("Resources/form-input-list.json");
fields = json?.fields;
}
private class FormData
{
public Metadata metadata { get; set; }
public Field[] fields { get; set; }
}
private class Metadata
{
public int version { get; set; }
public string project { get; set; }
}
private class Field
{
public string type { get; set; }
public string id { get; set; }
public string name { get; set; }
public string labelText { get; set; }
public string helperText { get; set; }
public bool isRequired { get; set; }
public Item[] items { get; set; }
public string placeholderText { get; set; }
}
private class Item
{
public string id { get; set; }
public object value { get; set; }
public string labelText { get; set; }
}
}@code {
private Field[]? fields;
protected override async Task OnInitializedAsync()
{
var json = await Http.GetFromJsonAsync<FormData>("Resources/form-input-list.json");
fields = json?.fields;
}
private class FormData
{
public Metadata metadata { get; set; }
public Field[] fields { get; set; }
}
private class Metadata
{
public int version { get; set; }
public string project { get; set; }
}
private class Field
{
public string type { get; set; }
public string id { get; set; }
public string name { get; set; }
public string labelText { get; set; }
public string helperText { get; set; }
public bool isRequired { get; set; }
public Item[] items { get; set; }
public string placeholderText { get; set; }
}
private class Item
{
public string id { get; set; }
public object value { get; set; }
public string labelText { get; set; }
}
}using nhs_frontend_csharp.frontend.Components;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddHttpClient();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:8081/") });
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
}
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();using nhs_frontend_csharp.frontend.Components;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddHttpClient();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:8081/") });
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
}
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();