build script for maui apk adjusted 2 #2

Open
itob wants to merge 29 commits from development into master
5 changed files with 48 additions and 11 deletions
Showing only changes of commit 18fd6d6f59 - Show all commits

View File

@ -1,7 +1,13 @@
using CommunityToolkit.Maui;
using CommunityToolkit.Maui.Markup;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using RBLNews.Maui.Services;
using RBLNews.Shared.Models;
using RBLNews.Shared.Services;
using RBLNews.Shared.Services.Contracts;
namespace RBLNews.Maui
{
@ -22,7 +28,7 @@ namespace RBLNews.Maui
builder.Services.AddMauiBlazorWebView();
builder.Services.AddBlazorBootstrap();
builder.Services.AddSingleton<IConfigService, ConfigService>();
builder.Services.AddSingleton<IFeedDataService, FeedDataService>();
builder.Services.AddSingleton<AppLifecycleService>();
@ -33,15 +39,11 @@ namespace RBLNews.Maui
MauiApp app = builder.Build();
using var serviceScope = app.Services.CreateScope();
var services = serviceScope.ServiceProvider;
AppSettingsModel? appSettings = app.Configuration.GetSection("App").Get<AppSettingsModel>();
var environmentVariablesService = services.GetRequiredService<EnvironmentVariablesService>();
string? backendApiUrl = environmentVariablesService.RblApiUrl;
if (string.IsNullOrEmpty(backendApiUrl))
if (string.IsNullOrEmpty(appSettings?.BackendApiUrl))
{
throw new Exception($"can't instantiate services, due to paramters are null. backendApiUrl: '{backendApiUrl}'");
throw new Exception($"can't instantiate services, due to paramters are null. backendApiUrl: '{appSettings?.BackendApiUrl}'");
}
return app;

View File

@ -90,6 +90,21 @@
<Folder Include="IaC\" />
</ItemGroup>
<ItemGroup>
<Content Include="..\RBLNews.Shared\wwwroot\appsettings.Development.json">
<Link>wwwroot\appsettings.Development.json</Link>
</Content>
<Content Include="..\RBLNews.Shared\wwwroot\appsettings.json">
<Link>wwwroot\appsettings.json</Link>
</Content>
<Content Include="..\RBLNews.Shared\wwwroot\appsettings.Production.json">
<Link>wwwroot\appsettings.Production.json</Link>
</Content>
<Content Include="..\RBLNews.Shared\wwwroot\appsettings.Test.json">
<Link>wwwroot\appsettings.Test.json</Link>
</Content>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties XamarinHotReloadDebuggerTimeoutExceptionRBLNewsMauiHideInfoBar="True" /></VisualStudio></ProjectExtensions>
</Project>

View File

@ -0,0 +1,20 @@
using Microsoft.Extensions.Configuration;
using RBLNews.Shared.Models;
using RBLNews.Shared.Services.Contracts;
namespace RBLNews.Maui.Services;
public class ConfigService : IConfigService
{
public AppSettingsModel? AppSettings { get; }
public ConfigService(IConfiguration configuration)
{
this.AppSettings = configuration.GetSection("App").Get<AppSettingsModel>();
if(this.AppSettings == null)
{
throw new NullReferenceException("App settings not found");
}
}
}

View File

@ -4,5 +4,5 @@ namespace RBLNews.Shared.Services.Contracts;
public interface IConfigService
{
AppSettingsModel AppSettings { get; }
AppSettingsModel? AppSettings { get; }
}

View File

@ -5,7 +5,7 @@ namespace RBLNews.Web.Services;
public class ConfigService : IConfigService
{
public AppSettingsModel AppSettings { get; }
public AppSettingsModel? AppSettings { get; }
public ConfigService(IConfiguration configuration)
{