items = repository.List();
-
- IDataProtector protector = provider.CreateProtector("AddressValidation.Demo.Settings.V1");
-
- Data = items.Select(s => new
- {
- s.Key,
- Value = s.IsEncrypted ? protector.Unprotect(s.Value) : s.Value
- }).ToDictionary(k => k.Key, string? (v) => v.Value);
- }
- catch ( SqliteException )
- {
- }
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Configuration/SqliteConfigurationSource.cs b/demo/src/AddressValidation.Demo/Configuration/SqliteConfigurationSource.cs
deleted file mode 100644
index a7d0f9b..0000000
--- a/demo/src/AddressValidation.Demo/Configuration/SqliteConfigurationSource.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace AddressValidation.Demo.Configuration;
-
-internal sealed class SqliteConfigurationSource : IConfigurationSource
-{
- public IConfigurationProvider Build(IConfigurationBuilder builder)
- {
- return new SqliteConfigurationProvider();
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Data/countries+states.db b/demo/src/AddressValidation.Demo/Data/countries+states.db
deleted file mode 100644
index d0933aa..0000000
Binary files a/demo/src/AddressValidation.Demo/Data/countries+states.db and /dev/null differ
diff --git a/demo/src/AddressValidation.Demo/Dockerfile b/demo/src/AddressValidation.Demo/Dockerfile
deleted file mode 100644
index b5b5960..0000000
--- a/demo/src/AddressValidation.Demo/Dockerfile
+++ /dev/null
@@ -1,12 +0,0 @@
-FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled-extra@sha256:1ec4c9605a8fc97d3c2045d46557e51d9ca54ba4f91339205be2e44bfb184732
-
-WORKDIR /app
-
-COPY --chown=$APP_UID:$APP_UID .nuke/temp/AddressValidation.Demo/ .
-
-ENV ASPNETCORE_HTTP_PORTS=3000
-EXPOSE 3000
-
-USER $APP_UID
-
-ENTRYPOINT ["dotnet", "AddressValidation.Demo.dll"]
diff --git a/demo/src/AddressValidation.Demo/Extensions/ConfigurationBuilderExtensions.cs b/demo/src/AddressValidation.Demo/Extensions/ConfigurationBuilderExtensions.cs
deleted file mode 100644
index ac83c8c..0000000
--- a/demo/src/AddressValidation.Demo/Extensions/ConfigurationBuilderExtensions.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace AddressValidation.Demo.Extensions;
-
-using Configuration;
-
-internal static class ConfigurationBuilderExtensions
-{
- public static IConfigurationBuilder AddSqlite(this IConfigurationBuilder builder)
- {
- ArgumentNullException.ThrowIfNull(builder);
- return builder.Add(new SqliteConfigurationSource());
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Features/.editorconfig b/demo/src/AddressValidation.Demo/Features/.editorconfig
deleted file mode 100644
index 377bce4..0000000
--- a/demo/src/AddressValidation.Demo/Features/.editorconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# see https://github.com/dotnet/sdk/issues/39817
-
-[*.razor.cs]
-dotnet_diagnostic.CA1822.severity = suggestion
-dotnet_diagnostic.CA1823.severity = suggestion
-dotnet_diagnostic.IDE0044.severity = suggestion
-dotnet_diagnostic.IDE0051.severity = suggestion
-dotnet_diagnostic.IDE0052.severity = suggestion
-dotnet_diagnostic.IDE0060.severity = none
-dotnet_diagnostic.S1144.severity = suggestion
diff --git a/demo/src/AddressValidation.Demo/Features/Error.razor b/demo/src/AddressValidation.Demo/Features/Error.razor
deleted file mode 100644
index b9571fc..0000000
--- a/demo/src/AddressValidation.Demo/Features/Error.razor
+++ /dev/null
@@ -1,40 +0,0 @@
-@page "/Error"
-@using System.Diagnostics
-
-Error
-
-Error.
-An error occurred while processing your request.
-
-@if (ShowRequestId)
-{
-
- Request ID: @RequestId
-
-}
-
-Development Mode
-
- Swapping to Development environment will display more detailed information about the error that
- occurred.
-
-
- The Development environment shouldn't be enabled for deployed applications.
- It can result in displaying sensitive information from exceptions to end users.
- For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT
- environment variable to Development
- and restarting the app.
-
-
-@code{
- [CascadingParameter] private HttpContext? HttpContext { get; set; }
-
- private string? RequestId { get; set; }
- private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
-
- protected override void OnInitialized()
- {
- RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
- }
-
-}
diff --git a/demo/src/AddressValidation.Demo/Features/Index.razor b/demo/src/AddressValidation.Demo/Features/Index.razor
deleted file mode 100644
index c9291d4..0000000
--- a/demo/src/AddressValidation.Demo/Features/Index.razor
+++ /dev/null
@@ -1,3 +0,0 @@
-@page "/"
-
-Address Validation Demo
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/Abstractions/AbstractValidatorComponent.cs b/demo/src/AddressValidation.Demo/Features/Validators/Abstractions/AbstractValidatorComponent.cs
deleted file mode 100644
index 5ce66a4..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/Abstractions/AbstractValidatorComponent.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-namespace AddressValidation.Demo.Features.Validators.Abstractions;
-
-using System.Text.Json;
-using Common.Components;
-using Microsoft.JSInterop;
-using Models.Forms.Abstractions;
-using Radzen;
-using Services.Abstractions;
-using Visus.AddressValidation.Abstractions;
-using Visus.AddressValidation.Http;
-using Visus.AddressValidation.Model;
-using Visus.AddressValidation.Services;
-
-public abstract class AbstractValidatorComponent : ComponentBase
- where TValidationRequest : AbstractAddressValidationRequest, new()
- where TValidationFormModel : AbstractAddressValidationFormModel, new()
-{
- private readonly JsonSerializerOptions _serializerOptions = new()
- {
- WriteIndented = true
- };
-
- protected TValidationFormModel AddressValidationFormModel { get; } = new();
-
- protected bool IsCityOrTownDisabled
- {
- get
- {
- if ( string.IsNullOrWhiteSpace(AddressValidationFormModel.CityOrTown) ||
- string.IsNullOrWhiteSpace(AddressValidationFormModel.StateOrProvince) )
- {
- return false;
- }
-
- string? stateOrProvinceName = Provinces!.GetValueOrDefault(AddressValidationFormModel.StateOrProvince);
-
- return !string.IsNullOrWhiteSpace(stateOrProvinceName)
- && string.Equals(stateOrProvinceName,
- AddressValidationFormModel.CityOrTown,
- StringComparison.OrdinalIgnoreCase);
- }
- }
-
- [Inject]
- protected IConfiguration Configuration { get; set; } = null!;
-
- protected IReadOnlyDictionary Countries { get; private set; } = new Dictionary();
-
- [Inject]
- protected IGeographyService GeographyService { get; set; } = null!;
-
- [Inject]
- protected IJSRuntime JsRuntime { get; set; } = null!;
-
- [Inject]
- protected NotificationService NotificationService { get; set; } = null!;
-
- protected IReadOnlyDictionary Provinces { get; private set; } = new Dictionary();
-
- protected MarkupString? RequestJson { get; private set; }
-
- protected LoadingIndicator RequestLoadingIndicator { get; set; } = null!;
-
- protected MarkupString? ResponseJson { get; private set; }
-
- protected LoadingIndicator ResponseLoadingIndicator { get; set; } = null!;
-
- protected LoadingIndicator SettingsLoadingIndicator { get; set; } = null!;
-
- [Inject]
- protected ISettingsService SettingsService { get; set; } = null!;
-
- protected LoadingIndicator ValidateLoadingIndicator { get; set; } = null!;
-
- [Inject]
- protected IAddressValidationService ValidationService { get; set; } = null!;
-
- protected virtual IEnumerable InitializeCountries()
- {
- yield break;
- }
-
- protected async Task OnAddressValidationFormSubmitAsync()
- {
- await ValidateLoadingIndicator.ShowAsync();
- await RequestLoadingIndicator.ShowAsync();
- await ResponseLoadingIndicator.ShowAsync();
-
- try
- {
- await RenderRequestJsonAsync();
-
- IAddressValidationResponse? result = await ValidationService.ValidateAsync(AddressValidationFormModel.Request);
- if ( result is not null )
- {
- await RenderResponseJsonAsync(result);
- }
- }
- finally
- {
- await ValidateLoadingIndicator.HideAsync();
- await RequestLoadingIndicator.HideAsync();
- await ResponseLoadingIndicator.HideAsync();
- }
- }
-
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- if ( !firstRender )
- {
- return;
- }
-
- await ValidateLoadingIndicator.ShowAsync();
-
- try
- {
- await Task.WhenAll(LoadCountriesAsync(), OnCountryChangedAsync());
- }
- finally
- {
- await ValidateLoadingIndicator.HideAsync();
- }
- }
-
- protected Task OnCountryChangedAsync()
- {
- if ( string.IsNullOrWhiteSpace(AddressValidationFormModel.Country) )
- {
- return Task.CompletedTask;
- }
-
- return Task.Run(async () => await GeographyService.ListProvincesAsDictionaryAsync(AddressValidationFormModel.Country))
- .ContinueWith(t =>
- {
- Provinces = t.Result;
- }, CancellationToken.None, TaskContinuationOptions.LongRunning, TaskScheduler.Default);
- }
-
- protected override void OnInitialized()
- {
- AddressValidationFormModel.Country = nameof(CountryCode.US);
- }
-
- protected Task OnProvinceChangedAsync()
- {
- if ( string.IsNullOrWhiteSpace(AddressValidationFormModel.Country) ||
- string.IsNullOrWhiteSpace(AddressValidationFormModel.StateOrProvince) )
- {
- return Task.CompletedTask;
- }
-
- return Task.Run(async () => await GeographyService.ListAutonomousCitiesAsync(AddressValidationFormModel.Country))
- .ContinueWith(t =>
- {
- string? stateOrProvinceName = Provinces.GetValueOrDefault(AddressValidationFormModel.StateOrProvince);
- if ( !string.IsNullOrWhiteSpace(stateOrProvinceName) && t.Result.Contains(stateOrProvinceName) )
- {
- AddressValidationFormModel.CityOrTown = stateOrProvinceName;
- }
- }, CancellationToken.None, TaskContinuationOptions.LongRunning, TaskScheduler.Default);
- }
-
- private Task LoadCountriesAsync()
- {
- return Task.Run(async () => await GeographyService.ListCountriesAsDictionaryAsync())
- .ContinueWith(t =>
- {
- Countries = t.Result;
- }, CancellationToken.None, TaskContinuationOptions.LongRunning, TaskScheduler.Default);
- }
-
- private async Task RenderRequestJsonAsync()
- {
- string json = AddressValidationFormModel.ToJson();
- string result = await JsRuntime.InvokeAsync("highlightJson", json);
-
- RequestJson = new MarkupString(result);
- }
-
- private async Task RenderResponseJsonAsync(IAddressValidationResponse response)
- {
- string json = JsonSerializer.Serialize(response, _serializerOptions);
- string result = await JsRuntime.InvokeAsync("highlightJson", json);
-
- ResponseJson = new MarkupString(result);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/FedEx.razor b/demo/src/AddressValidation.Demo/Features/Validators/FedEx.razor
deleted file mode 100644
index ac2d242..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/FedEx.razor
+++ /dev/null
@@ -1,242 +0,0 @@
-@page "/validator/fedex"
-@using AddressValidation.Demo.Models.Forms
-@using Visus.AddressValidation.Abstractions
-@inherits AddressValidation.Demo.Features.Validators.Abstractions.AbstractValidatorComponent
-
-FedEx Address Validation
-
-FedEx Address Validation Dem1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @if (Provinces.Count > 0)
- {
-
- }
- else
- {
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @ResponseJson
-
-
-
-
- @RequestJson
-
-
-
-
-
-
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/FedEx.razor.cs b/demo/src/AddressValidation.Demo/Features/Validators/FedEx.razor.cs
deleted file mode 100644
index 466254a..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/FedEx.razor.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-namespace AddressValidation.Demo.Features.Validators;
-
-using System.Diagnostics.CodeAnalysis;
-using Abstractions;
-using Configuration;
-using Models.Forms;
-using Radzen;
-using Visus.AddressValidation.Abstractions;
-using Visus.AddressValidation.Integration.FedEx;
-using Visus.AddressValidation.Integration.FedEx.Http;
-
-[SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix")]
-public partial class FedEx : AbstractValidatorComponent
-{
- private readonly Dictionary _clientEnvironments = new(StringComparer.OrdinalIgnoreCase)
- {
- [nameof(ClientEnvironment.DEVELOPMENT)] = ClientEnvironment.DEVELOPMENT,
- [nameof(ClientEnvironment.PRODUCTION)] = ClientEnvironment.PRODUCTION
- };
-
- private readonly OAuthApiSettingsFormModel _settingsFormModel = new();
-
- protected override IEnumerable InitializeCountries()
- {
- return Constants.SupportedCountries;
- }
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
-
- _settingsFormModel.AccountNumber = Configuration.GetValue(Constants.AccountNumberConfigurationKey);
-
- string? clientEnvironmentValue = Configuration.GetValue(Constants.ClientEnvironmentConfigurationKey);
- if ( !Enum.TryParse(clientEnvironmentValue, out ClientEnvironment clientEnvironment) )
- {
- _settingsFormModel.ClientEnvironment = ClientEnvironment.DEVELOPMENT;
- }
-
- _settingsFormModel.ClientEnvironment = clientEnvironment;
- _settingsFormModel.ClientId = Configuration.GetValue(Constants.ClientIdConfigurationKey);
- _settingsFormModel.ClientSecret = Configuration.GetValue(Constants.ClientSecretConfigurationKey);
- }
-
- private async Task OnSettingsFormSubmitAsync()
- {
- await SettingsLoadingIndicator.ShowAsync();
-
- try
- {
- bool[] results =
- [
- await SettingsService.AddOrUpdateAsync(Constants.AccountNumberConfigurationKey, _settingsFormModel.AccountNumber),
- await SettingsService.AddOrUpdateAsync(Constants.ClientEnvironmentConfigurationKey, _settingsFormModel.ClientEnvironment.ToString()),
- await SettingsService.AddOrUpdateAsync(Constants.ClientIdConfigurationKey, _settingsFormModel.ClientId, true),
- await SettingsService.AddOrUpdateAsync(Constants.ClientSecretConfigurationKey, _settingsFormModel.ClientSecret, true)
- ];
-
- if ( results.All(a => a) )
- {
- NotificationService.Notify(NotificationSeverity.Success, "Configuration Updated");
-
- // remark: refresh underlying IConfiguration provider for validation services
- if ( Configuration is IConfigurationRoot configurationRoot )
- {
- IConfigurationProvider? provider = configurationRoot.Providers.FirstOrDefault(f => f is SqliteConfigurationProvider);
- provider?.Load();
- }
- }
- else
- {
- NotificationService.Notify(NotificationSeverity.Error, "Configuration Update Failed");
- }
- }
- finally
- {
- await SettingsLoadingIndicator.HideAsync();
- }
-
- await InvokeAsync(StateHasChanged);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/Google.razor b/demo/src/AddressValidation.Demo/Features/Validators/Google.razor
deleted file mode 100644
index 2fc7f33..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/Google.razor
+++ /dev/null
@@ -1,222 +0,0 @@
-@page "/validator/google"
-@using AddressValidation.Demo.Models.Forms
-@inherits AddressValidation.Demo.Features.Validators.Abstractions.AbstractValidatorComponent
-
-Google Address Validation Demo
-
-Google Address Validation Demo
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @if (Provinces.Count > 0)
- {
-
- }
- else
- {
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @RequestJson
-
-
-
-
- @ResponseJson
-
-
-
-
-
-
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/Google.razor.cs b/demo/src/AddressValidation.Demo/Features/Validators/Google.razor.cs
deleted file mode 100644
index 3fe11c7..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/Google.razor.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-namespace AddressValidation.Demo.Features.Validators;
-
-using Abstractions;
-using Configuration;
-using Models.Forms;
-using Radzen;
-using Visus.AddressValidation.Abstractions;
-using Visus.AddressValidation.Integration.Google.Http;
-using Constants = Visus.AddressValidation.Integration.Google.Constants;
-
-public partial class Google : AbstractValidatorComponent
-{
- private readonly GoogleApiSettingsFormModel _settingsFormModel = new();
-
- protected override IEnumerable InitializeCountries()
- {
- return Constants.SupportedCountries;
- }
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
-
- _settingsFormModel.PrivateKey = Configuration.GetValue(Constants.PrivateKeyConfigurationKey);
- _settingsFormModel.ProjectId = Configuration.GetValue(Constants.ProjectIdConfigurationKey);
- _settingsFormModel.ServiceAccountEmailAddress = Configuration.GetValue(Constants.ServiceAccountEmailConfigurationKey);
- }
-
- private async Task OnSettingsFormSubmitAsync()
- {
- await SettingsLoadingIndicator.ShowAsync();
-
- try
- {
- bool[] results =
- [
- await SettingsService.AddOrUpdateAsync(Constants.PrivateKeyConfigurationKey, _settingsFormModel.PrivateKey, true),
- await SettingsService.AddOrUpdateAsync(Constants.ProjectIdConfigurationKey, _settingsFormModel.ProjectId),
- await SettingsService.AddOrUpdateAsync(Constants.ServiceAccountEmailConfigurationKey, _settingsFormModel.ServiceAccountEmailAddress)
- ];
-
- if ( results.All(a => a) )
- {
- NotificationService.Notify(NotificationSeverity.Success, "Configuration Updated");
-
- // remark: refresh underlying IConfiguration provider for validation services
- if ( Configuration is IConfigurationRoot configurationRoot )
- {
- IConfigurationProvider? provider = configurationRoot.Providers.FirstOrDefault(f => f is SqliteConfigurationProvider);
- provider?.Load();
- }
- }
- else
- {
- NotificationService.Notify(NotificationSeverity.Error, "Configuration Update Failed");
- }
- }
- finally
- {
- await SettingsLoadingIndicator.HideAsync();
- }
-
- await InvokeAsync(StateHasChanged);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/PitneyBowes.razor b/demo/src/AddressValidation.Demo/Features/Validators/PitneyBowes.razor
deleted file mode 100644
index 83f969f..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/PitneyBowes.razor
+++ /dev/null
@@ -1,239 +0,0 @@
-@page "/validator/pitney-bowes"
-@using AddressValidation.Demo.Models.Forms
-@using Visus.AddressValidation.Abstractions
-@inherits AddressValidation.Demo.Features.Validators.Abstractions.AbstractValidatorComponent
-
-Pitney Bowes Address Validator
-
-Pitney Bowes Address Validation Demo
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @if (Provinces.Count > 0)
- {
-
- }
- else
- {
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @RequestJson
-
-
-
-
- @ResponseJson
-
-
-
-
-
-
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/PitneyBowes.razor.cs b/demo/src/AddressValidation.Demo/Features/Validators/PitneyBowes.razor.cs
deleted file mode 100644
index 5c816a5..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/PitneyBowes.razor.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-namespace AddressValidation.Demo.Features.Validators;
-
-using Abstractions;
-using Configuration;
-using Models.Forms;
-using Radzen;
-using Visus.AddressValidation.Abstractions;
-using Visus.AddressValidation.Integration.PitneyBowes;
-using Visus.AddressValidation.Integration.PitneyBowes.Http;
-
-public partial class PitneyBowes : AbstractValidatorComponent
-{
- private readonly Dictionary _clientEnvironments = new(StringComparer.OrdinalIgnoreCase)
- {
- [nameof(ClientEnvironment.DEVELOPMENT)] = ClientEnvironment.DEVELOPMENT,
- [nameof(ClientEnvironment.PRODUCTION)] = ClientEnvironment.PRODUCTION
- };
-
- private readonly PitneyBowesApiSettingsFormModel _settingsFormModel = new();
-
- protected override IEnumerable InitializeCountries()
- {
- return Constants.SupportedCountries;
- }
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
-
- _settingsFormModel.DeveloperId = Configuration.GetValue(Constants.DeveloperIdConfigurationKey);
-
- string? clientEnvironmentValue = Configuration.GetValue(Constants.ClientEnvironmentConfigurationKey);
- if ( !Enum.TryParse(clientEnvironmentValue, out ClientEnvironment clientEnvironment) )
- {
- _settingsFormModel.ClientEnvironment = ClientEnvironment.DEVELOPMENT;
- }
-
- _settingsFormModel.ClientEnvironment = clientEnvironment;
- _settingsFormModel.ApiKey = Configuration.GetValue(Constants.ApiKeyConfigurationKey);
- _settingsFormModel.ApiSecret = Configuration.GetValue(Constants.ApiSecretConfigurationKey);
- }
-
- private async Task OnSettingsFormSubmitAsync()
- {
- await SettingsLoadingIndicator.ShowAsync();
-
- try
- {
- bool[] results =
- [
- await SettingsService.AddOrUpdateAsync(Constants.DeveloperIdConfigurationKey, _settingsFormModel.DeveloperId),
- await SettingsService.AddOrUpdateAsync(Constants.ClientEnvironmentConfigurationKey, _settingsFormModel.ClientEnvironment.ToString()),
- await SettingsService.AddOrUpdateAsync(Constants.ApiKeyConfigurationKey, _settingsFormModel.ApiKey, true),
- await SettingsService.AddOrUpdateAsync(Constants.ApiSecretConfigurationKey, _settingsFormModel.ApiSecret, true)
- ];
-
- if ( results.All(a => a) )
- {
- NotificationService.Notify(NotificationSeverity.Success, "Configuration Updated");
-
- // remark: refresh underlying IConfiguration provider for validation services
- if ( Configuration is IConfigurationRoot configurationRoot )
- {
- IConfigurationProvider? provider = configurationRoot.Providers.FirstOrDefault(f => f is SqliteConfigurationProvider);
- provider?.Load();
- }
- }
- else
- {
- NotificationService.Notify(NotificationSeverity.Error, "Configuration Update Failed");
- }
- }
- finally
- {
- await SettingsLoadingIndicator.HideAsync();
- }
-
- await InvokeAsync(StateHasChanged);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/Ups.razor b/demo/src/AddressValidation.Demo/Features/Validators/Ups.razor
deleted file mode 100644
index 8539915..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/Ups.razor
+++ /dev/null
@@ -1,242 +0,0 @@
-@page "/validator/ups"
-@using AddressValidation.Demo.Models.Forms
-@using Visus.AddressValidation.Abstractions
-@inherits AddressValidation.Demo.Features.Validators.Abstractions.AbstractValidatorComponent
-
-UPS Address Validation
-
-UPS Address Validation Demo
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @if (Provinces.Count > 0)
- {
-
- }
- else
- {
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @RequestJson
-
-
-
-
- @ResponseJson
-
-
-
-
-
-
-
diff --git a/demo/src/AddressValidation.Demo/Features/Validators/Ups.razor.cs b/demo/src/AddressValidation.Demo/Features/Validators/Ups.razor.cs
deleted file mode 100644
index d45ac91..0000000
--- a/demo/src/AddressValidation.Demo/Features/Validators/Ups.razor.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-namespace AddressValidation.Demo.Features.Validators;
-
-using Abstractions;
-using Configuration;
-using Models.Forms;
-using Radzen;
-using Visus.AddressValidation.Abstractions;
-using Visus.AddressValidation.Integration.Ups;
-using Visus.AddressValidation.Integration.Ups.Http;
-
-public partial class Ups : AbstractValidatorComponent
-{
- private readonly Dictionary _clientEnvironments = new(StringComparer.OrdinalIgnoreCase)
- {
- [nameof(ClientEnvironment.DEVELOPMENT)] = ClientEnvironment.DEVELOPMENT,
- [nameof(ClientEnvironment.PRODUCTION)] = ClientEnvironment.PRODUCTION
- };
-
- private readonly OAuthApiSettingsFormModel _settingsFormModel = new();
-
- protected override IEnumerable InitializeCountries()
- {
- return Constants.SupportedCountries;
- }
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
-
- _settingsFormModel.AccountNumber = Configuration.GetValue(Constants.AccountNumberConfigurationKey);
-
- string? clientEnvironmentValue = Configuration.GetValue(Constants.ClientEnvironmentConfigurationKey);
- if ( !Enum.TryParse(clientEnvironmentValue, out ClientEnvironment clientEnvironment) )
- {
- _settingsFormModel.ClientEnvironment = ClientEnvironment.DEVELOPMENT;
- }
-
- _settingsFormModel.ClientEnvironment = clientEnvironment;
- _settingsFormModel.ClientId = Configuration.GetValue(Constants.ClientIdConfigurationKey);
- _settingsFormModel.ClientSecret = Configuration.GetValue(Constants.ClientSecretConfigurationKey);
- }
-
- private async Task OnSettingsFormSubmitAsync()
- {
- await SettingsLoadingIndicator.ShowAsync();
-
- try
- {
- bool[] results =
- [
- await SettingsService.AddOrUpdateAsync(Constants.AccountNumberConfigurationKey, _settingsFormModel.AccountNumber),
- await SettingsService.AddOrUpdateAsync(Constants.ClientEnvironmentConfigurationKey, _settingsFormModel.ClientEnvironment.ToString()),
- await SettingsService.AddOrUpdateAsync(Constants.ClientIdConfigurationKey, _settingsFormModel.ClientId, true),
- await SettingsService.AddOrUpdateAsync(Constants.ClientSecretConfigurationKey, _settingsFormModel.ClientSecret, true)
- ];
-
- if ( results.All(a => a) )
- {
- NotificationService.Notify(NotificationSeverity.Success, "Configuration Updated");
-
- // remark: refresh underlying IConfiguration provider for validation services
- if ( Configuration is IConfigurationRoot configurationRoot )
- {
- IConfigurationProvider? provider = configurationRoot.Providers.FirstOrDefault(f => f is SqliteConfigurationProvider);
- provider?.Load();
- }
- }
- else
- {
- NotificationService.Notify(NotificationSeverity.Error, "Configuration Update Failed");
- }
- }
- finally
- {
- await SettingsLoadingIndicator.HideAsync();
- }
-
- await InvokeAsync(StateHasChanged);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/GlobalSupression.cs b/demo/src/AddressValidation.Demo/GlobalSupression.cs
deleted file mode 100644
index ade9e36..0000000
--- a/demo/src/AddressValidation.Demo/GlobalSupression.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-
-[assembly: SuppressMessage("Reliability",
- "CA2007:Do not directly await a Task",
- Justification = "Discouraged for Blazor UI Components",
- Scope = "namespaceanddescendants",
- Target = "~N:AddressValidation.Demo.Common")]
-
-[assembly: SuppressMessage("Reliability",
- "CA2007:Do not directly await a Task",
- Justification = "Discouraged for Blazor UI Components",
- Scope = "namespaceanddescendants",
- Target = "~N:AddressValidation.Demo.Features")]
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Configuration/CountryConfig.cs b/demo/src/AddressValidation.Demo/Infrastructure/Configuration/CountryConfig.cs
deleted file mode 100644
index 9d4470a..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Configuration/CountryConfig.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Configuration;
-
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-using Models.Entities;
-
-public sealed class CountryConfig : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- ArgumentNullException.ThrowIfNull(builder);
-
- builder.HasKey(p => p.Id);
-
- builder.ToTable("countries");
-
- builder.Property(p => p.Id).IsRequired();
- builder.Property(p => p.Name).IsRequired().HasMaxLength(100);
- builder.Property(p => p.IsoCode).HasColumnName("iso2").IsRequired().HasMaxLength(2);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Configuration/SettingsConfig.cs b/demo/src/AddressValidation.Demo/Infrastructure/Configuration/SettingsConfig.cs
deleted file mode 100644
index 26d8575..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Configuration/SettingsConfig.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Configuration;
-
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-using Models.Entities;
-
-public sealed class SettingsConfig : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- ArgumentNullException.ThrowIfNull(builder);
-
- builder.HasKey(p => p.Key);
-
- builder.ToTable("Settings");
-
- builder.Property(p => p.Key).ValueGeneratedNever().IsRequired().HasMaxLength(255).IsUnicode(false);
- builder.Property(p => p.Value).IsUnicode().HasMaxLength(int.MaxValue);
- builder.Property(p => p.IsEncrypted).IsRequired().HasDefaultValue(false);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Configuration/StateConfig.cs b/demo/src/AddressValidation.Demo/Infrastructure/Configuration/StateConfig.cs
deleted file mode 100644
index 6fe20c1..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Configuration/StateConfig.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Configuration;
-
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-using Models.Entities;
-
-public sealed class StateConfig : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- ArgumentNullException.ThrowIfNull(builder);
-
- builder.HasKey(p => p.Id);
-
- builder.ToTable("states");
-
- builder.Property(p => p.CountryCode).HasColumnName("country_code").IsRequired().HasMaxLength(2);
- builder.Property(p => p.Id).IsRequired();
- builder.Property(p => p.Name).IsRequired().HasMaxLength(100);
- builder.Property(p => p.IsoCode).HasColumnName("iso2").IsRequired().HasMaxLength(255);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/GeoContext.cs b/demo/src/AddressValidation.Demo/Infrastructure/GeoContext.cs
deleted file mode 100644
index ff11384..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/GeoContext.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure;
-
-using Configuration;
-using Microsoft.EntityFrameworkCore;
-using Models.Entities;
-
-public sealed class GeoContext(DbContextOptions options) : DbContext(options)
-{
- public DbSet Countries { get; set; }
-
- public DbSet States { get; set; }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- ArgumentNullException.ThrowIfNull(modelBuilder);
-
- modelBuilder.ApplyConfiguration(new CountryConfig());
- modelBuilder.ApplyConfiguration(new StateConfig());
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/GeoContextFactory.cs b/demo/src/AddressValidation.Demo/Infrastructure/GeoContextFactory.cs
deleted file mode 100644
index 653363c..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/GeoContextFactory.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure;
-
-using Microsoft.EntityFrameworkCore;
-
-public sealed class GeoContextFactory(ILoggerFactory loggerFactory) : IDbContextFactory
-{
- private readonly ILoggerFactory _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
-
- public GeoContext CreateDbContext()
- {
- DbContextOptionsBuilder options = new();
-
- string database = Path.Join(AppDomain.CurrentDomain.GetData("DataDirectory")!.ToString(), "countries+states.db");
-
- options.UseSqlite($"Data Source={database}");
-
- options.UseLoggerFactory(_loggerFactory);
- options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
-
- return new GeoContext(options.Options);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ICountryRepository.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ICountryRepository.cs
deleted file mode 100644
index 60c52fc..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ICountryRepository.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using Models.Entities;
-
-public interface ICountryRepository : ISqlRepository
-{
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ISettingsRepository.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ISettingsRepository.cs
deleted file mode 100644
index cf5e26c..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ISettingsRepository.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using Models.Entities;
-
-public interface ISettingsRepository : ISqlRepository
-{
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ISqlRepository.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ISqlRepository.cs
deleted file mode 100644
index 94f0be9..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/ISqlRepository.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using Microsoft.EntityFrameworkCore.Query;
-
-public interface ISqlRepository
- where TEntity : class, new()
-{
- ValueTask AddAsync(TEntity entity, CancellationToken cancellationToken = default);
-
- ValueTask AnyAsync(CancellationToken cancellationToken = default);
-
- ValueTask AnyAsync(Expression> predicate, CancellationToken cancellationToken = default);
-
- ValueTask CountAsync(CancellationToken cancellationToken = default);
-
- ValueTask CountAsync(Expression> predicate, CancellationToken cancellationToken = default);
-
- ValueTask DeleteAsync(TEntity entity, CancellationToken cancellationToken = default);
-
- ValueTask DeleteAsync(Expression> predicate, CancellationToken cancellationToken = default);
-
- ValueTask GetAsync(Expression> predicate, CancellationToken cancellationToken = default);
-
- ValueTask> ListAsync(CancellationToken cancellationToken = default);
-
- ValueTask> ListAsync(Expression> keySelector, CancellationToken cancellationToken = default);
-
- ValueTask> ListAsync(Expression> predicate, Expression> keySelector, CancellationToken cancellationToken = default);
-
- ValueTask> ListAsync(Expression> predicate, CancellationToken cancellationToken = default);
-
- ValueTask LongCountAsync(CancellationToken cancellationToken = default);
-
- ValueTask LongCountAsync(Expression> predicate, CancellationToken cancellationToken = default);
-
- ValueTask MaxAsync(CancellationToken cancellationToken = default);
-
- ValueTask MaxAsync(Expression> predicate, CancellationToken cancellationToken = default);
-
- ValueTask MinAsync(CancellationToken cancellationToken = default);
-
- ValueTask MinAsync(Expression> predicate, CancellationToken cancellationToken = default);
-
- ValueTask UpdateAsync(TEntity entity, CancellationToken cancellationToken = default);
-
- ValueTask UpdateAsync(Expression> predicate, Expression, SetPropertyCalls>> statements, CancellationToken cancellationToken = default);
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/IStateRepository.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/IStateRepository.cs
deleted file mode 100644
index 214ca36..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/IStateRepository.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using Models.Entities;
-
-public interface IStateRepository : ISqlRepository
-{
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Add.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Add.cs
deleted file mode 100644
index 10f51b1..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Add.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public ValueTask AddAsync(TEntity entity, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(entity);
-
- return !HasPrimaryKey
- ? ValueTask.FromResult(false)
- : AddInternalAsync(entity, cancellationToken);
- }
-
- private async ValueTask AddInternalAsync(TEntity entity, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- context.Set().Add(entity);
-
- return await SaveChangesAsync(context, cancellationToken).ConfigureAwait(false);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Any.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Any.cs
deleted file mode 100644
index 419f3df..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Any.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public async ValueTask AnyAsync(CancellationToken cancellationToken = default)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().AnyAsync(cancellationToken).ConfigureAwait(false);
- }
-
- public ValueTask AnyAsync(Expression> predicate, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return AnyInternalAsync(predicate, cancellationToken);
- }
-
- private async ValueTask AnyInternalAsync(Expression> predicate, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().Where(predicate).AnyAsync(cancellationToken).ConfigureAwait(false);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Count.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Count.cs
deleted file mode 100644
index f503d17..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Count.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public async ValueTask CountAsync(CancellationToken cancellationToken = default)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().CountAsync(cancellationToken).ConfigureAwait(false);
- }
-
- public ValueTask CountAsync(Expression> predicate, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return CountInternalAsync(predicate, cancellationToken);
- }
-
- public async ValueTask LongCountAsync(CancellationToken cancellationToken = default)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().LongCountAsync(cancellationToken).ConfigureAwait(false);
- }
-
- public ValueTask LongCountAsync(Expression> predicate, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return LongCountInternalAsync(predicate, cancellationToken);
- }
-
- private async ValueTask CountInternalAsync(Expression> predicate, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().CountAsync(predicate, cancellationToken).ConfigureAwait(false);
- }
-
- private async ValueTask LongCountInternalAsync(Expression> predicate, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().LongCountAsync(predicate, cancellationToken).ConfigureAwait(false);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Delete.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Delete.cs
deleted file mode 100644
index 3988cbf..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Delete.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public ValueTask DeleteAsync(TEntity entity, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(entity);
-
- return !HasPrimaryKey
- ? ValueTask.FromResult(false)
- : DeleteInternalAsync(entity, cancellationToken);
- }
-
- public ValueTask DeleteAsync(Expression> predicate, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return DeleteInternalAsync(predicate, cancellationToken);
- }
-
- private async ValueTask DeleteInternalAsync(TEntity entity, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- context.Set().Remove(entity);
-
- return await SaveChangesAsync(context, cancellationToken).ConfigureAwait(false);
- }
-
- private async ValueTask DeleteInternalAsync(Expression> predicate, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().Where(predicate).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false) >= 0;
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Get.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Get.cs
deleted file mode 100644
index b694f10..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Get.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public ValueTask GetAsync(Expression> predicate, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return GetInternalAsync(predicate, cancellationToken);
- }
-
- private async ValueTask GetInternalAsync(Expression> predicate, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().Where(predicate).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.List.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.List.cs
deleted file mode 100644
index e99b387..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.List.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public async ValueTask> ListAsync(CancellationToken cancellationToken = default)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().ToListAsync(cancellationToken).ConfigureAwait(false);
- }
-
- public ValueTask> ListAsync(Expression> keySelector, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(nameof(keySelector));
- return ListInternalAsync(keySelector, cancellationToken);
- }
-
- public ValueTask> ListAsync(Expression> predicate, Expression> keySelector, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(nameof(predicate));
- ArgumentNullException.ThrowIfNull(nameof(keySelector));
- return ListInternalAsync(predicate, keySelector, cancellationToken);
- }
-
- public ValueTask> ListAsync(Expression> predicate, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return ListInternalAsync(predicate, cancellationToken);
- }
-
- private async ValueTask> ListInternalAsync(Expression> predicate, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().Where(predicate).ToListAsync(cancellationToken).ConfigureAwait(false);
- }
-
- private async ValueTask> ListInternalAsync(Expression> keySelector, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().Select(keySelector).ToListAsync(cancellationToken).ConfigureAwait(false);
- }
-
- private async ValueTask> ListInternalAsync(Expression> predicate, Expression> keySelector, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set()
- .Where(predicate)
- .Select(keySelector)
- .ToListAsync(cancellationToken)
- .ConfigureAwait(false);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Max.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Max.cs
deleted file mode 100644
index e7169cf..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Max.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public async ValueTask MaxAsync(CancellationToken cancellationToken = default)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().MaxAsync(cancellationToken).ConfigureAwait(false);
- }
-
- public ValueTask MaxAsync(Expression> predicate, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return MaxInternalAsync(predicate, cancellationToken);
- }
-
- private async ValueTask MaxInternalAsync(Expression> predicate, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().MaxAsync(predicate, cancellationToken).ConfigureAwait(false);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Min.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Min.cs
deleted file mode 100644
index e6e0816..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Min.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public async ValueTask MinAsync(CancellationToken cancellationToken = default)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().MinAsync(cancellationToken).ConfigureAwait(false);
- }
-
- public ValueTask MinAsync(Expression> predicate, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return MinInternalAsync(predicate, cancellationToken);
- }
-
- private async ValueTask MinInternalAsync(Expression> predicate, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().MinAsync(predicate, cancellationToken).ConfigureAwait(false);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Update.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Update.cs
deleted file mode 100644
index c5f736d..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.Update.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Query;
-
-public abstract partial class SqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- public ValueTask UpdateAsync(TEntity entity, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(entity);
-
- return !HasPrimaryKey
- ? ValueTask.FromResult(false)
- : UpdateInternalAsync(entity, cancellationToken);
- }
-
- public ValueTask UpdateAsync(Expression> predicate, Expression, SetPropertyCalls>> statements, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(predicate);
- return UpdateInternalAsync(predicate, statements, cancellationToken);
- }
-
- private async ValueTask UpdateInternalAsync(TEntity entity, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- context.Set().Update(entity);
-
- return await SaveChangesAsync(context, cancellationToken).ConfigureAwait(false);
- }
-
- private async ValueTask UpdateInternalAsync(Expression> predicate, Expression, SetPropertyCalls>> statements, CancellationToken cancellationToken)
- {
- TContext context = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using ConfiguredAsyncDisposable _ = context.ConfigureAwait(false);
-
- return await context.Set().Where(predicate).ExecuteUpdateAsync(statements, cancellationToken).ConfigureAwait(false) >= 0;
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.cs
deleted file mode 100644
index 32032bb..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/Abstractions/SqlRepository.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories.Abstractions;
-
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata;
-
-public abstract partial class SqlRepository : ISqlRepository
- where TEntity : class, new()
- where TContext : DbContext
-{
- [SuppressMessage("ReSharper", "StaticMemberInGenericType")]
- private static readonly Action LogDbUpdateException =
- LoggerMessage.Define(LogLevel.Error,
- new EventId(2203, nameof(SaveChangesAsync)),
- "{Message}: {@Exception}");
-
- private readonly Lazy> _columns;
-
- private readonly IDbContextFactory _contextFactory;
-
- private readonly ILogger> _logger;
-
- private readonly Lazy> _primaryKeys;
-
- private readonly Lazy _schemaName;
-
- private readonly Lazy _tableName;
-
- protected SqlRepository(IDbContextFactory contextFactory, ILogger> logger)
- {
- _contextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory));
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-
- // note: must be initialized first
- _schemaName = new Lazy(GetEntitySchemaName);
- _tableName = new Lazy(GetEntityTableName);
-
- _columns = new Lazy>(GetEntityColumns);
- _primaryKeys = new Lazy>(GetEntityPrimaryKeys);
- }
-
- protected IReadOnlyDictionary Columns => _columns.Value;
-
- [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
- protected bool HasPrimaryKey => _primaryKeys.Value.Any();
-
- protected IReadOnlyList PrimaryKeys => _primaryKeys.Value;
-
- protected string? SchemaName => _schemaName.Value;
-
- protected string? TableName => _tableName.Value;
-
- [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
- protected async ValueTask SaveChangesAsync(TContext context, CancellationToken cancellationToken = default)
- {
- ArgumentNullException.ThrowIfNull(context);
-
- try
- {
- bool result = await context.SaveChangesAsync(cancellationToken).ConfigureAwait(false) > 0;
-
- // Note: intentional as we are working in a 'disconnected' state.
- context.ChangeTracker.Clear();
-
- return result;
- }
- catch ( DbUpdateException e )
- {
- LogDbUpdateException(_logger, e, e.Message, null);
- }
-
- return false;
- }
-
- private Dictionary GetEntityColumns()
- {
- if ( string.IsNullOrWhiteSpace(_tableName.Value) )
- {
- return new Dictionary();
- }
-
- StoreObjectIdentifier storeObjectIdentifier = StoreObjectIdentifier.Table(_tableName.Value, _schemaName.Value);
-
- using TContext context = _contextFactory.CreateDbContext();
-
- return context.Model.FindEntityType(typeof(TEntity))?.GetProperties()
- .Where(w => string.IsNullOrWhiteSpace(w.GetComputedColumnSql(storeObjectIdentifier)) &&
- ( w.ValueGenerated & ValueGenerated.OnAddOrUpdate ) != ValueGenerated.OnAddOrUpdate)
- .ToDictionary(d => d.Name, d => d.GetColumnName(storeObjectIdentifier)) ?? new Dictionary();
- }
-
- private IReadOnlyList GetEntityPrimaryKeys()
- {
- using TContext context = _contextFactory.CreateDbContext();
- return context.Model.FindEntityType(typeof(TEntity))?.FindPrimaryKey()?.Properties ?? new List().AsReadOnly();
- }
-
- private string? GetEntitySchemaName()
- {
- using TContext context = _contextFactory.CreateDbContext();
- return context.Model.FindEntityType(typeof(TEntity))?.GetSchema();
- }
-
- private string? GetEntityTableName()
- {
- using TContext context = _contextFactory.CreateDbContext();
- return context.Model.FindEntityType(typeof(TEntity))?.GetTableName();
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/CountryRepository.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/CountryRepository.cs
deleted file mode 100644
index c8ac3cc..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/CountryRepository.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories;
-
-using Abstractions;
-using Microsoft.EntityFrameworkCore;
-using Models.Entities;
-
-public sealed class CountryRepository(IDbContextFactory contextFactory, ILogger logger)
- : SqlRepository(contextFactory, logger), ICountryRepository;
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/SettingsRepository.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/SettingsRepository.cs
deleted file mode 100644
index e22aceb..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/SettingsRepository.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories;
-
-using Abstractions;
-using Microsoft.EntityFrameworkCore;
-using Models.Entities;
-
-public sealed class SettingsRepository(
- IDbContextFactory contextFactory,
- ILogger logger) : SqlRepository(contextFactory, logger), ISettingsRepository
-{
- private readonly IDbContextFactory _contextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory));
-
- public IReadOnlyList List()
- {
- using SettingsContext context = _contextFactory.CreateDbContext();
- return context.Set().ToList().AsReadOnly();
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/StateRepository.cs b/demo/src/AddressValidation.Demo/Infrastructure/Repositories/StateRepository.cs
deleted file mode 100644
index a0c8b64..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/Repositories/StateRepository.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure.Repositories;
-
-using Abstractions;
-using Microsoft.EntityFrameworkCore;
-using Models.Entities;
-
-public sealed class StateRepository(IDbContextFactory contextFactory, ILogger> logger)
- : SqlRepository(contextFactory, logger), IStateRepository;
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/SettingsContext.cs b/demo/src/AddressValidation.Demo/Infrastructure/SettingsContext.cs
deleted file mode 100644
index e9cff42..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/SettingsContext.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure;
-
-using Configuration;
-using Microsoft.EntityFrameworkCore;
-using Models.Entities;
-
-public sealed class SettingsContext(DbContextOptions options) : DbContext(options)
-{
- public DbSet Config { get; set; }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- ArgumentNullException.ThrowIfNull(modelBuilder);
-
- modelBuilder.ApplyConfiguration(new SettingsConfig());
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Infrastructure/SettingsContextFactory.cs b/demo/src/AddressValidation.Demo/Infrastructure/SettingsContextFactory.cs
deleted file mode 100644
index d6455b4..0000000
--- a/demo/src/AddressValidation.Demo/Infrastructure/SettingsContextFactory.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace AddressValidation.Demo.Infrastructure;
-
-using Microsoft.EntityFrameworkCore;
-
-public sealed class SettingsContextFactory(ILoggerFactory loggerFactory) : IDbContextFactory
-{
- private readonly ILoggerFactory _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
-
- public SettingsContext CreateDbContext()
- {
- DbContextOptionsBuilder options = new();
-
- string database = Path.Join(AppDomain.CurrentDomain.GetData("DataDirectory")!.ToString(), "settings.db");
-
- options.UseSqlite($"Data Source={database}");
-
- options.UseLoggerFactory(_loggerFactory);
- options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
-
- return new SettingsContext(options.Options);
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Entities/CountryModel.cs b/demo/src/AddressValidation.Demo/Models/Entities/CountryModel.cs
deleted file mode 100644
index 7d11b6b..0000000
--- a/demo/src/AddressValidation.Demo/Models/Entities/CountryModel.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace AddressValidation.Demo.Models.Entities;
-
-public sealed class CountryModel
-{
- public int Id { get; set; }
-
- public string IsoCode { get; set; } = null!;
-
- public string Name { get; set; } = null!;
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Entities/SettingsModel.cs b/demo/src/AddressValidation.Demo/Models/Entities/SettingsModel.cs
deleted file mode 100644
index c9cc1f0..0000000
--- a/demo/src/AddressValidation.Demo/Models/Entities/SettingsModel.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-#nullable disable
-
-namespace AddressValidation.Demo.Models.Entities;
-
-using System.ComponentModel.DataAnnotations.Schema;
-
-public class SettingsModel
-{
- [Column(Order = 2)]
- public bool IsEncrypted { get; set; }
-
- [Column(Order = 0)]
- public string Key { get; set; }
-
- [Column(Order = 1)]
- public string Value { get; set; }
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Entities/StateModel.cs b/demo/src/AddressValidation.Demo/Models/Entities/StateModel.cs
deleted file mode 100644
index e7ad470..0000000
--- a/demo/src/AddressValidation.Demo/Models/Entities/StateModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace AddressValidation.Demo.Models.Entities;
-
-public sealed class StateModel
-{
- public string CountryCode { get; set; } = null!;
-
- public int Id { get; set; }
-
- public string IsoCode { get; set; } = null!;
-
- public string Name { get; set; } = null!;
-
- public string? Type { get; set; }
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Forms/Abstractions/AbstractAddressValidationFormModel.cs b/demo/src/AddressValidation.Demo/Models/Forms/Abstractions/AbstractAddressValidationFormModel.cs
deleted file mode 100644
index 35f4fa1..0000000
--- a/demo/src/AddressValidation.Demo/Models/Forms/Abstractions/AbstractAddressValidationFormModel.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-namespace AddressValidation.Demo.Models.Forms.Abstractions;
-
-using System.Text.Json;
-using Visus.AddressValidation.Abstractions;
-using Visus.AddressValidation.Http;
-
-public abstract class AbstractAddressValidationFormModel
- where TRequest : AbstractAddressValidationRequest, new()
-{
- private readonly Dictionary _addressLines = new()
- {
- { 0, null },
- { 1, null }
- };
-
- private readonly JsonSerializerOptions _serializerOptions = new()
- {
- WriteIndented = true
- };
-
- public TRequest Request { get; } = new();
-
- public string? AddressLine1
- {
- get => _addressLines[0];
- set
- {
- _addressLines[0] = value;
- UpdateAddressLines();
- }
- }
-
- public string? AddressLine2
- {
- get => _addressLines[1];
- set
- {
- _addressLines[1] = value;
- UpdateAddressLines();
- }
- }
-
- public string? CityOrTown
- {
- get => Request.CityOrTown;
- set => Request.CityOrTown = value;
- }
-
- public string? Country
- {
- get => Request.Country.ToString();
- set
- {
- if ( string.IsNullOrWhiteSpace(value) )
- {
- Request.Country = null;
- return;
- }
-
- if ( Enum.TryParse(value, true, out CountryCode result) )
- {
- Request.Country = result;
- return;
- }
-
- Request.Country = null;
- }
- }
-
- public string? PostalCode
- {
- get => Request.PostalCode;
- set => Request.PostalCode = value;
- }
-
- public string? StateOrProvince
- {
- get => Request.StateOrProvince;
- set => Request.StateOrProvince = value;
- }
-
- public string ToJson()
- {
- return JsonSerializer.Serialize(Request, _serializerOptions);
- }
-
- private void UpdateAddressLines()
- {
- Request.AddressLines.Clear();
-
- foreach ( ( int _, string? value ) in _addressLines.OrderBy(o => o.Key) )
- {
- if ( string.IsNullOrWhiteSpace(value) )
- {
- continue;
- }
-
- Request.AddressLines.Add(value);
- }
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Forms/FedExAddressValidationFormModel.cs b/demo/src/AddressValidation.Demo/Models/Forms/FedExAddressValidationFormModel.cs
deleted file mode 100644
index 433fc59..0000000
--- a/demo/src/AddressValidation.Demo/Models/Forms/FedExAddressValidationFormModel.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace AddressValidation.Demo.Models.Forms;
-
-using Abstractions;
-using Visus.AddressValidation.Integration.FedEx.Http;
-
-public sealed class FedExAddressValidationFormModel : AbstractAddressValidationFormModel;
diff --git a/demo/src/AddressValidation.Demo/Models/Forms/GoogleAddressValidationFormModel.cs b/demo/src/AddressValidation.Demo/Models/Forms/GoogleAddressValidationFormModel.cs
deleted file mode 100644
index c8616c8..0000000
--- a/demo/src/AddressValidation.Demo/Models/Forms/GoogleAddressValidationFormModel.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace AddressValidation.Demo.Models.Forms;
-
-using Abstractions;
-using Visus.AddressValidation.Integration.Google.Http;
-
-public sealed class GoogleAddressValidationFormModel : AbstractAddressValidationFormModel;
diff --git a/demo/src/AddressValidation.Demo/Models/Forms/GoogleApiSettingsFormModel.cs b/demo/src/AddressValidation.Demo/Models/Forms/GoogleApiSettingsFormModel.cs
deleted file mode 100644
index 65b8b1c..0000000
--- a/demo/src/AddressValidation.Demo/Models/Forms/GoogleApiSettingsFormModel.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-namespace AddressValidation.Demo.Models.Forms;
-
-public sealed class GoogleApiSettingsFormModel
-{
- private string? _privateKey;
-
- public string? PrivateKey
- {
- get => _privateKey;
- set
- {
- if ( string.IsNullOrWhiteSpace(value) )
- {
- _privateKey = null;
- return;
- }
-
- if ( value.Contains("\\n", StringComparison.OrdinalIgnoreCase) )
- {
- value = value.Replace("\\n", Environment.NewLine, StringComparison.OrdinalIgnoreCase);
- }
-
- _privateKey = value;
- }
- }
-
- public string? ProjectId { get; set; }
-
- public string? ServiceAccountEmailAddress { get; set; }
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Forms/OAuthApiSettingsFormModel.cs b/demo/src/AddressValidation.Demo/Models/Forms/OAuthApiSettingsFormModel.cs
deleted file mode 100644
index d659016..0000000
--- a/demo/src/AddressValidation.Demo/Models/Forms/OAuthApiSettingsFormModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace AddressValidation.Demo.Models.Forms;
-
-using Visus.AddressValidation.Abstractions;
-
-public class OAuthApiSettingsFormModel
-{
- public string? AccountNumber { get; set; }
-
- public ClientEnvironment ClientEnvironment { get; set; } = ClientEnvironment.DEVELOPMENT;
-
- public string? ClientId { get; set; }
-
- public string? ClientSecret { get; set; }
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Forms/PitneyBowesAddressValidationFormModel.cs b/demo/src/AddressValidation.Demo/Models/Forms/PitneyBowesAddressValidationFormModel.cs
deleted file mode 100644
index f7b24f5..0000000
--- a/demo/src/AddressValidation.Demo/Models/Forms/PitneyBowesAddressValidationFormModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace AddressValidation.Demo.Models.Forms;
-
-using Abstractions;
-using Visus.AddressValidation.Integration.PitneyBowes.Http;
-
-public sealed class PitneyBowesAddressValidationFormModel : AbstractAddressValidationFormModel
-{
- public bool IncludeSuggestions
- {
- get => Request.IncludeSuggestions;
- set => Request.IncludeSuggestions = value;
- }
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Forms/PitneyBowesApiSettingsFormModel.cs b/demo/src/AddressValidation.Demo/Models/Forms/PitneyBowesApiSettingsFormModel.cs
deleted file mode 100644
index 15b99a5..0000000
--- a/demo/src/AddressValidation.Demo/Models/Forms/PitneyBowesApiSettingsFormModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace AddressValidation.Demo.Models.Forms;
-
-using Visus.AddressValidation.Abstractions;
-
-public class PitneyBowesApiSettingsFormModel
-{
- public string? ApiKey { get; set; }
-
- public string? ApiSecret { get; set; }
-
- public ClientEnvironment ClientEnvironment { get; set; } = ClientEnvironment.DEVELOPMENT;
-
- public string? DeveloperId { get; set; }
-}
diff --git a/demo/src/AddressValidation.Demo/Models/Forms/UpsAddressValidationFormModel.cs b/demo/src/AddressValidation.Demo/Models/Forms/UpsAddressValidationFormModel.cs
deleted file mode 100644
index d14d9c6..0000000
--- a/demo/src/AddressValidation.Demo/Models/Forms/UpsAddressValidationFormModel.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace AddressValidation.Demo.Models.Forms;
-
-using Abstractions;
-using Visus.AddressValidation.Integration.Ups.Http;
-
-public sealed class UpsAddressValidationFormModel : AbstractAddressValidationFormModel;
diff --git a/demo/src/AddressValidation.Demo/Program.cs b/demo/src/AddressValidation.Demo/Program.cs
deleted file mode 100644
index 7b28983..0000000
--- a/demo/src/AddressValidation.Demo/Program.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-namespace AddressValidation.Demo;
-
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using Extensions;
-using Infrastructure;
-using Infrastructure.Repositories;
-using Infrastructure.Repositories.Abstractions;
-using Microsoft.AspNetCore.DataProtection;
-using Microsoft.EntityFrameworkCore;
-using Radzen;
-using Serilog;
-using Serilog.Events;
-using Serilog.Sinks.SystemConsole.Themes;
-using Services;
-using Services.Abstractions;
-using Visus.AddressValidation.Integration.FedEx.Extensions;
-using Visus.AddressValidation.Integration.Google.Extensions;
-using Visus.AddressValidation.Integration.PitneyBowes.Extensions;
-using Visus.AddressValidation.Integration.Ups.Extensions;
-
-[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")]
-[SuppressMessage("Design", "CA1031:Do not catch general exception types")]
-internal static class Program
-{
- public static async Task Main(string[] args)
- {
- Log.Logger = new LoggerConfiguration()
- .MinimumLevel.Debug()
- .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
- .Enrich.FromLogContext()
- .Enrich.WithThreadId()
- .Enrich.WithMachineName()
- .WriteTo.Console(formatProvider: CultureInfo.InvariantCulture, theme: AnsiConsoleTheme.Code)
- .WriteTo.ApplicationInsights(TelemetryConverter.Traces)
- .CreateBootstrapLogger();
-
- try
- {
- WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
-
- AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(builder.Environment.ContentRootPath, "Data"));
-
- builder.Configuration.AddSqlite();
-
- builder.Services.AddDataProtection()
- .SetApplicationName("AddressValidation.Demo")
- .PersistKeysToFileSystem(new DirectoryInfo(Path.Combine(builder.Environment.ContentRootPath, "Data", "Keys")));
-
- builder.Services.AddApplicationInsightsTelemetry();
-
- builder.Services.AddDbContextFactory();
- builder.Services.AddDbContextFactory();
-
- builder.Services.AddRadzenComponents();
- builder.Services.AddRazorComponents().AddInteractiveServerComponents();
-
- builder.Services.AddScoped();
- builder.Services.AddScoped();
- builder.Services.AddScoped();
-
- builder.Services.AddDistributedMemoryCache();
-
- builder.Services.AddFedExAddressValidation();
- builder.Services.AddGoogleAddressValidation();
- builder.Services.AddPitneyBowesAddressValidation();
- builder.Services.AddUpsAddressValidation();
-
- builder.Services.AddTransient();
- builder.Services.AddScoped();
- builder.Services.AddTransient();
-
- builder.Services.AddSerilog();
-
- WebApplication app = builder.Build();
-
- if ( !app.Environment.IsDevelopment() )
- {
- app.UseExceptionHandler("/Error");
- app.UseHsts();
- }
-
- app.UseHttpsRedirection();
-
- app.UseStaticFiles();
- app.UseAntiforgery();
-
- app.MapRazorComponents