Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor Hybrid android #1320

Merged
merged 111 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
2c04ca2
import frontend work from setup blazor web branch
hahn-kev Dec 4, 2024
5fbd11f
import fw lite desktop changes
hahn-kev Dec 4, 2024
0a1ea77
import fw lite shared blazor changes
hahn-kev Dec 4, 2024
0cfd98b
import local web app changes
hahn-kev Dec 4, 2024
1819b61
tweak type generation to support async and i async enumerable, as wel…
hahn-kev Dec 4, 2024
d657b1f
continue polishing type generation, pull out multi-string to allow a …
hahn-kev Dec 6, 2024
769dc7f
rewrite `fetchProjects` to `localProjects`, let js call dotnet method…
hahn-kev Dec 6, 2024
f7ec94e
develop a way to map services between js and dotnet
hahn-kev Dec 6, 2024
8863c59
expose more services and use them from HomeView.svelte
hahn-kev Dec 6, 2024
e7ef1ab
commit generated ts types
hahn-kev Dec 6, 2024
bfff2d4
Merge branch 'refs/heads/develop' into feat/blazor-hybrid
hahn-kev Dec 6, 2024
05f7c9f
add create project api and call from home page
hahn-kev Dec 6, 2024
22e9b14
fix server authority issues
hahn-kev Dec 6, 2024
89111d9
wire up js invokable miniLcm service for crdts and fwdata
hahn-kev Dec 6, 2024
bb818e6
create dotnet project view to solve late binding of api service, fix …
hahn-kev Dec 6, 2024
e89f690
remove reference which was breaking android build of FwLiteDesktop
hahn-kev Dec 6, 2024
664f92b
dont set TargetFramework in build props as that prevents projects fro…
hahn-kev Dec 6, 2024
e2b99a3
fix some broken stuff due to services not existing
hahn-kev Dec 6, 2024
1d5a9d6
fix android app icon missing issue
hahn-kev Dec 6, 2024
f1b73a6
remove usage of `toSorted` which is not supported on older android ph…
hahn-kev Dec 9, 2024
dcfebb8
allow invoking logout/login via js
hahn-kev Dec 9, 2024
9c81f76
remove unused constructor fields on entry component change
hahn-kev Dec 9, 2024
bdba9d7
populate datacache when injecting a crdt project to the active scope
hahn-kev Dec 9, 2024
7f8ecf2
configure oauth client to support protocol handler on android to allo…
hahn-kev Dec 9, 2024
dc14a6e
fix port forwarding for staging
hahn-kev Dec 9, 2024
3fb2c1d
Merge branch 'refs/heads/develop' into feat/blazor-hybrid
hahn-kev Dec 13, 2024
6eb33aa
refactor some service setup after merge
hahn-kev Dec 13, 2024
bc080cb
refactor IsPackagedApp into IsPortableApp
hahn-kev Dec 13, 2024
34c2552
refactor FwLiteProvider to use constant for js function name and simp…
hahn-kev Dec 13, 2024
0973774
change svelte app binding to look for `id="svelte-app"` instead of ju…
hahn-kev Dec 13, 2024
db8e929
fix compile issues and dependency missmatch
hahn-kev Dec 13, 2024
07ff5de
prevent svelte from catching navigation to allow blazor to handle it,…
hahn-kev Dec 13, 2024
7c21439
setup watch builder build task
hahn-kev Dec 13, 2024
e98faaf
fix issue with rollup not resolving $lib
hahn-kev Dec 16, 2024
f31f371
configure linq2db to use the Microsoft SQLite library instead of syst…
hahn-kev Dec 16, 2024
5ee022d
prevent throwing errors when sending change notifications fails after…
hahn-kev Dec 16, 2024
0b3b21f
ensure hosted services run at startup as expected
hahn-kev Dec 16, 2024
bcca0d6
return the project when setting active project context
hahn-kev Dec 16, 2024
9ad5e32
!fixup ensure hosted services run at startup as expected
hahn-kev Dec 16, 2024
5a3722e
make all methods return async in generated ts code, support ValueTask
hahn-kev Dec 16, 2024
fca878b
update generated types
hahn-kev Dec 16, 2024
465f98e
connect js event bus to C# ChangeEventBus
hahn-kev Dec 16, 2024
94fd1bd
remove ProjectContext.cs and use stateful CurrentProjectService.cs in…
hahn-kev Dec 16, 2024
353d78a
correct nrt error
hahn-kev Dec 17, 2024
bb6a3f8
update swashbuckle version to fix build error
hahn-kev Dec 17, 2024
8a4b354
ignore csproj.user files
hahn-kev Dec 17, 2024
e6af4e4
remove unused layout files
hahn-kev Dec 17, 2024
bb94fa3
dispose of the module properly when the SvelteLayout is disposed of
hahn-kev Dec 17, 2024
33aa391
change crdt project pages to use OwningComponentBase which ensures th…
hahn-kev Dec 17, 2024
8dfe1ba
pass in jsRuntime as a parameter to FwLiteProvider rather than inject…
hahn-kev Dec 17, 2024
4335e05
make login buttons reactive
hahn-kev Dec 17, 2024
674a3ac
remove unused components
hahn-kev Dec 17, 2024
67dd28a
create an async disposing OwningComponentBase and use it for project …
hahn-kev Dec 17, 2024
4e3ce27
fix app header under status bar issue on android, ensure that status …
hahn-kev Dec 17, 2024
a2a73d4
use hsl color space rather than oklch to support older browsers on ol…
hahn-kev Dec 17, 2024
807e7f1
remove unused generated types
hahn-kev Dec 17, 2024
a8b6c3a
ensure that a specific target framework is set.
hahn-kev Dec 17, 2024
75e80ed
!fixup remove unused generated types
hahn-kev Dec 17, 2024
57b1c8b
configure `fw-lite:maui-desktop` task to run build-viewer-app
hahn-kev Dec 17, 2024
4288963
remove deleted generated file from index
hahn-kev Dec 17, 2024
1501ab8
update caniuse-lite
hahn-kev Dec 17, 2024
c2f8a14
specify condition for windows related properties
hahn-kev Dec 17, 2024
52f3514
refactor FwDataProjectContext.cs to be scoped and not a singleton
hahn-kev Dec 18, 2024
681ee30
make miniLcm disposable
hahn-kev Dec 18, 2024
522912e
refactor FieldWorksProjectList.cs and CrdtProjectsService.cs into a c…
hahn-kev Dec 18, 2024
f1999b8
refactor project import to make it optional. if import is called at r…
hahn-kev Dec 18, 2024
4001121
refactor FwShared to not depend on FwDataBridge, put that dependency …
hahn-kev Dec 18, 2024
46abe33
fix circular dependency between FieldWorksProjectList and FwDataFactory
hahn-kev Dec 18, 2024
050768c
ensure lcm service is cleared when going home
hahn-kev Dec 18, 2024
32f7085
update typegen
hahn-kev Dec 18, 2024
c845a13
only enable fwdata bridge when building for windows
hahn-kev Dec 18, 2024
3c3a487
use supportsFwData to determine if we show the fieldworks column
hahn-kev Dec 18, 2024
bf4b63a
introduce DurableInvoke helper which uses a method defined on window …
hahn-kev Dec 18, 2024
0a6ec60
always export methods as promises when converting from c# to TS
hahn-kev Dec 18, 2024
599e6b5
Replace remaining oklch colors
myieye Dec 18, 2024
1f526af
Add global error handling and tidy up error notifications
myieye Dec 18, 2024
a47095e
Explicitly empty viewer app out dir to prevent unexpected residue
myieye Dec 18, 2024
17a7bed
Add finally blocks to home view actions
myieye Dec 18, 2024
2df2aff
fix compile error in test
hahn-kev Dec 19, 2024
a5f1aa1
don't always copy Mercurial stuff
hahn-kev Dec 19, 2024
21fc21f
mark tests as slow
hahn-kev Dec 19, 2024
aa5067c
keep `CurrentProjectService` scoped when running tests
hahn-kev Dec 19, 2024
68e5f37
Merge branch 'develop' into feat/blazor-hybrid
hahn-kev Dec 19, 2024
382cbd4
fix frontend build issue because viewer output file was renamed
hahn-kev Dec 19, 2024
f4149cb
migrate away from types in viewer/lib/mini-lcm and use generated dotn…
hahn-kev Dec 19, 2024
c147442
make ProjectView about optional
hahn-kev Dec 19, 2024
a6cf3a7
resolve import errors when importing code to the frontend from the vi…
hahn-kev Dec 19, 2024
8bb8cba
change fw-lite build to use ubunut-latest on main build
hahn-kev Dec 19, 2024
9c454c3
build android
hahn-kev Dec 19, 2024
653975f
build maui on windows
hahn-kev Dec 19, 2024
0705281
fix eslint errors
hahn-kev Dec 19, 2024
c6d8fb9
specify os when building for android
hahn-kev Dec 19, 2024
7422da2
don't import Dotnet service in viewer because it breaks the build
hahn-kev Dec 19, 2024
7510dcb
make release depend on the publish-android job
hahn-kev Dec 19, 2024
a094d13
build android on mac, run tests on ubuntu, fix windows build
hahn-kev Dec 19, 2024
db1db88
remove setup maui from initial build since it doesn't work on linux
hahn-kev Dec 19, 2024
a099ff7
use windows for tests since linux doesn't seem to like the slnf file
hahn-kev Dec 19, 2024
81b42b9
install maui instead of maui-android
hahn-kev Dec 19, 2024
7bbfe75
fix os condition
hahn-kev Dec 19, 2024
8507512
Add Vs code tasks for FwLiteDesktop and android task
myieye Dec 19, 2024
44d2e47
avoid trimming SqliteConnection ClearAllPools
hahn-kev Dec 20, 2024
aba7a2c
publish single file when making portable windows builds
hahn-kev Dec 20, 2024
393eb6b
only use MsalCacheHelper on desktop platforms
hahn-kev Dec 20, 2024
21099b1
activate the desktop window once login is successful
hahn-kev Dec 20, 2024
62e07a2
Try to dispose service provider on shutdown
myieye Dec 20, 2024
0b9bfde
Make some JS more readable
myieye Dec 20, 2024
f75690b
Add FwLiteShared to FwLiteOnly.slnf
myieye Dec 20, 2024
bf505cd
remove typegen tool
hahn-kev Dec 20, 2024
413f83f
markup route parameters as services
hahn-kev Dec 20, 2024
6b987b1
enable file logging again
hahn-kev Dec 20, 2024
4c55686
Move comment
myieye Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
"dotnet-ef"
],
"rollForward": false
},
"dotnet-typegen": {
"version": "6.0.2",
"commands": [
"dotnet-typegen"
],
"rollForward": false
}
}
}
}
84 changes: 54 additions & 30 deletions .github/workflows/fw-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ on:
branches:
- develop
- main

env:
VIEWER_BUILD_OUTPUT_DIR: backend/FwLite/FwLiteShared/wwwroot/viewer
jobs:
build-and-test:
name: Build FW Lite and run tests
timeout-minutes: 30
timeout-minutes: 40
runs-on: windows-latest
outputs:
version: ${{ steps.setVersion.outputs.VERSION }}
Expand All @@ -40,9 +41,6 @@ jobs:
with:
node-version-file: './frontend/package.json'

- name: Setup Maui
run: dotnet workload install maui-windows

- name: Set Version
id: setVersion
shell: bash
Expand All @@ -59,20 +57,15 @@ jobs:
pnpm install
pnpm run build-app

- name: Dotnet build
working-directory: backend/FwLite/FwLiteDesktop
run: |
dotnet build --configuration Release

- name: Dotnet test
run: dotnet test FwLiteOnly.slnf --configuration Release --logger GitHubActions
run: dotnet test FwLiteOnly.slnf --logger GitHubActions

- name: Upload viewer artifacts
uses: actions/upload-artifact@v4
with:
name: fw-lite-viewer-app
name: fw-lite-viewer-js
if-no-files-found: error
path: frontend/viewer/dist
path: ${{ env.VIEWER_BUILD_OUTPUT_DIR }}

publish-mac:
name: Publish FW Lite app for Mac
Expand All @@ -86,8 +79,8 @@ jobs:
submodules: true
- uses: actions/download-artifact@v4
with:
name: fw-lite-viewer-app
path: frontend/viewer/dist
name: fw-lite-viewer-js
path: ${{ env.VIEWER_BUILD_OUTPUT_DIR }}
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
Expand Down Expand Up @@ -123,16 +116,12 @@ jobs:
submodules: true
- uses: actions/download-artifact@v4
with:
name: fw-lite-viewer-app
path: frontend/viewer/dist
name: fw-lite-viewer-js
path: ${{ env.VIEWER_BUILD_OUTPUT_DIR }}
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'

- name: Dotnet build
working-directory: backend/FwLite/LocalWebApp
run: dotnet build --configuration Release

- name: Publish Linux
working-directory: backend/FwLite/LocalWebApp
run: dotnet publish -r linux-x64 --artifacts-path ../artifacts -p:PublishSingleFile=true -p:Version=${{ needs.build-and-test.outputs.semver-version }}
Expand All @@ -144,6 +133,38 @@ jobs:
if-no-files-found: error
path: backend/FwLite/artifacts/publish/LocalWebApp/*

publish-android:
name: Publish FW Lite app for Android
needs: build-and-test
timeout-minutes: 30
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: fw-lite-viewer-js
path: ${{ env.VIEWER_BUILD_OUTPUT_DIR }}
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'

- name: Setup Maui
run: dotnet workload install maui

- name: Publish Android
working-directory: backend/FwLite/FwLiteDesktop
hahn-kev marked this conversation as resolved.
Show resolved Hide resolved
run: dotnet publish -f net9.0-android --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }}

- name: Upload FWLite App artifacts
uses: actions/upload-artifact@v4
with:
name: fw-lite-android
if-no-files-found: error
path: backend/FwLite/artifacts/publish/FwLiteDesktop/*/*

publish-win:
name: Publish FW Lite app for Windows
needs: build-and-test
Expand All @@ -156,30 +177,26 @@ jobs:
submodules: true
- uses: actions/download-artifact@v4
with:
name: fw-lite-viewer-app
path: frontend/viewer/dist
name: fw-lite-viewer-js
path: ${{ env.VIEWER_BUILD_OUTPUT_DIR }}
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'

- name: Setup Maui
run: dotnet workload install maui-windows

- name: Dotnet build
working-directory: backend/FwLite/LocalWebApp
run: dotnet build --configuration Release

- name: Publish Windows MAUI portable app
working-directory: backend/FwLite/FwLiteDesktop
run: |
dotnet publish -r win-x64 --artifacts-path ../artifacts -p:WindowsPackageType=None -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }}
dotnet publish -f net9.0-windows10.0.19041.0 --artifacts-path ../artifacts -p:WindowsPackageType=None -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }}
mkdir -p ../artifacts/sign/portable
cp -r ../artifacts/publish/FwLiteDesktop/* ../artifacts/sign/portable/

- name: Publish Windows MAUI msix app
working-directory: backend/FwLite/FwLiteDesktop
run: |
dotnet publish -r win-x64 --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }}
dotnet publish -f net9.0-windows10.0.19041.0 --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }}
mkdir -p ../artifacts/msix
cp ../artifacts/bin/FwLiteDesktop/*/AppPackages/*/*.msix ../artifacts/msix/

Expand Down Expand Up @@ -223,7 +240,7 @@ jobs:
create-release:
if: ${{ github.ref_name == 'main' }}
name: Create Release
needs: [ build-and-test, publish-win, publish-linux, publish-mac]
needs: [ build-and-test, publish-win, publish-linux, publish-mac, publish-android]
runs-on: ubuntu-latest

steps:
Expand All @@ -239,6 +256,10 @@ jobs:
with:
name: fw-lite-local-web-app-linux
path: fw-lite-local-web-app-linux
- uses: actions/download-artifact@v4
with:
name: fw-lite-android
path: fw-lite-android

- name: Zip artifacts
run: |
Expand All @@ -256,6 +277,9 @@ jobs:
fw-lite-msix/*
fw-lite-portable.zip
fw-lite-local-web-app-linux.zip
fw-lite-android/*.apk
fw-lite-android/*.aab

- name: Invalidate Lexbox Release endpoint
continue-on-error: true
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ artifacts/

#Verify
*.received.*
backend/FwLite/FwLiteShared/wwwroot/viewer

*.csproj.user
2 changes: 1 addition & 1 deletion backend/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<PropertyGroup>
<InformationalVersion>dev</InformationalVersion>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework Condition="'$(TargetFramework)' == ''">net9.0</TargetFramework>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions backend/FwHeadless/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static async Task<Results<Ok<SyncResult>, NotFound, ProblemHttpResult>> ExecuteM
}

static async Task<Results<Ok<ProjectSyncStatus>, NotFound>> GetMergeStatus(
ProjectContext projectContext,
CurrentProjectService projectContext,
ProjectLookupService projectLookupService,
SyncJobStatusService syncJobStatusService,
IServiceProvider services,
Expand All @@ -139,7 +139,7 @@ static async Task<Results<Ok<ProjectSyncStatus>, NotFound>> GetMergeStatus(
{
var jobStatus = syncJobStatusService.SyncStatus(projectId);
if (jobStatus == SyncJobStatus.Running) return TypedResults.Ok(ProjectSyncStatus.Syncing);
var project = projectContext.Project;
var project = projectContext.MaybeProject;
if (project is null)
{
// 404 only means "project doesn't exist"; if we don't know the status, then it hasn't synced before and is therefore ready to sync
Expand Down
3 changes: 1 addition & 2 deletions backend/FwHeadless/Services/ProjectContextFromIdService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public async Task PopulateProjectContext(HttpContext context, Func<Task> next)
if (File.Exists(crdtFile))
{
var project = new CrdtProject("crdt", crdtFile);
projectsService.SetProjectScope(project);
await context.RequestServices.GetRequiredService<CurrentProjectService>().PopulateProjectDataCache();
await context.RequestServices.GetRequiredService<CurrentProjectService>().SetupProjectContext(project);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

namespace FwDataMiniLcmBridge.Tests.Fixtures;

public class MockFwProjectList(IOptions<FwDataBridgeConfig> config, MockFwProjectLoader loader) : FieldWorksProjectList(config)
public class MockFwProjectList(IOptions<FwDataBridgeConfig> config, MockFwProjectLoader loader,
FwDataFactory fwDataFactory) : FieldWorksProjectList(config, fwDataFactory)
{
public override IEnumerable<IProjectIdentifier> EnumerateProjects()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ public ProjectLoaderFixture()
_config = provider.GetRequiredService<IOptions<FwDataBridgeConfig>>();
}

public FwDataMiniLcmApi CreateApi(string projectName)
{
return _fwDataFactory.GetFwDataMiniLcmApi(projectName, false);
}

public FwDataMiniLcmApi NewProjectApi(string projectName, string analysisWs, string vernacularWs)
{
projectName = $"{projectName}_{Guid.NewGuid()}";
MockFwProjectLoader.NewProject(new FwDataProject(projectName, _config.Value.ProjectsFolder), analysisWs, vernacularWs);
return CreateApi(projectName);
var fwDataProject = new FwDataProject(projectName, _config.Value.ProjectsFolder);
MockFwProjectLoader.NewProject(fwDataProject, analysisWs, vernacularWs);
return _fwDataFactory.GetFwDataMiniLcmApi(fwDataProject, false);
}

public void Dispose()
Expand Down
20 changes: 19 additions & 1 deletion backend/FwLite/FwDataMiniLcmBridge/FieldWorksProjectList.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
using FwDataMiniLcmBridge.LcmUtils;
using Microsoft.Extensions.Options;
using MiniLcm;
using MiniLcm.Models;
using MiniLcm.Project;

namespace FwDataMiniLcmBridge;

public class FieldWorksProjectList(IOptions<FwDataBridgeConfig> config)
public class FieldWorksProjectList(IOptions<FwDataBridgeConfig> config, FwDataFactory fwDataFactory) : IProjectProvider
{
public ProjectDataFormat DataFormat => ProjectDataFormat.FwData;
protected readonly IOptions<FwDataBridgeConfig> _config = config;
IEnumerable<IProjectIdentifier> IProjectProvider.ListProjects()
{
return EnumerateProjects();
}

IProjectIdentifier? IProjectProvider.GetProject(string name)
{
return GetProject(name);
}

public virtual IEnumerable<IProjectIdentifier> EnumerateProjects()
{
Expand All @@ -24,4 +36,10 @@ public virtual IEnumerable<IProjectIdentifier> EnumerateProjects()
{
return EnumerateProjects().OfType<FwDataProject>().FirstOrDefault(p => p.Name == name);
}

public IMiniLcmApi OpenProject(IProjectIdentifier project, bool saveOnDispose = true)
{
if (project is not FwDataProject fwDataProject) throw new ArgumentException("Project is not a fwdata project");
return fwDataFactory.GetFwDataMiniLcmApi(fwDataProject, saveOnDispose);
}
}
12 changes: 10 additions & 2 deletions backend/FwLite/FwDataMiniLcmBridge/FwDataBridgeKernel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FwDataMiniLcmBridge.LcmUtils;
using Microsoft.Extensions.DependencyInjection;
using MiniLcm;
using MiniLcm.Project;
using MiniLcm.Validators;

namespace FwDataMiniLcmBridge;
Expand All @@ -15,10 +16,17 @@ public static IServiceCollection AddFwDataBridge(this IServiceCollection service
services.AddOptions<FwDataBridgeConfig>().BindConfiguration("FwDataBridge");
services.AddSingleton<FwDataFactory>();
services.AddSingleton<FieldWorksProjectList>();
services.AddSingleton<IProjectProvider>(s => s.GetRequiredService<FieldWorksProjectList>());
services.AddSingleton<IProjectLoader, ProjectLoader>();
services.AddKeyedScoped<IMiniLcmApi>(FwDataApiKey, (provider, o) => provider.GetRequiredService<FwDataFactory>().GetCurrentFwDataMiniLcmApi(true));
services.AddKeyedScoped<IMiniLcmApi>(FwDataApiKey,
(provider, o) =>
{
var projectList = provider.GetRequiredService<FieldWorksProjectList>();
var projectContext = provider.GetRequiredService<FwDataProjectContext>();
return projectList.OpenProject(projectContext.Project ?? throw new InvalidOperationException("No project is set in the context."));
});
services.AddMiniLcmValidators();
services.AddSingleton<FwDataProjectContext>();
services.AddScoped<FwDataProjectContext>();
return services;
}
}
Loading
Loading