Skip to content

Commit 5e3cc29

Browse files
authored
feat: update extensition for injject service by IMasaBalzorBuilder (#781)
1 parent c17b088 commit 5e3cc29

File tree

4 files changed

+24
-36
lines changed

4 files changed

+24
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ bld/
3333

3434
# Visual Studio 2015/2017 cache/options directory
3535
.vs/
36+
.vscode/
3637
# Uncomment if you have tasks that create the project's static files in wwwroot
3738
#wwwroot/
3839

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/Masa.Stack.Components/Extensions/ServiceCollectionExtensions.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
2-
3-
namespace Masa.Stack.Components;
1+
namespace Masa.Stack.Components;
42

53
public static class ServiceCollectionExtensions
64
{
75
//Consider only one web clearance for now
86
public static IServiceCollection AddMasaStackComponent(this IServiceCollection services, MasaStackProject project,
97
string? i18nDirectoryPath = "wwwroot/i18n",
10-
string? authHost = null, string? mcHost = null, string? pmHost = null, bool microFrontend = false)
8+
string? authHost = null, string? mcHost = null, string? pmHost = null, bool microFrontend = false, Action<IMasaBlazorBuilder>? masaBalazorAction = default)
119
{
1210
ArgumentNullException.ThrowIfNull(project);
13-
AddMasaStackComponentsService(services, project, i18nDirectoryPath, authHost, mcHost, pmHost, microFrontend: microFrontend);
11+
AddMasaStackComponentsService(services, project, i18nDirectoryPath, authHost, mcHost, pmHost, microFrontend: microFrontend, masaBalazorAction: masaBalazorAction);
1412
AddObservable(services, true, project);
1513
return services;
1614
}
1715

1816
public static IServiceCollection AddMasaStackComponentsWithNormalApp(this IServiceCollection services, MasaStackProject project, string otlpUrl, string serviceVersion, string projectName = "default",
1917
string? i18nDirectoryPath = "wwwroot/i18n",
20-
string? authHost = null, string? mcHost = null, string? pmHost = null, bool microFrontend = false)
18+
string? authHost = null, string? mcHost = null, string? pmHost = null, bool microFrontend = false,
19+
Action<IMasaBlazorBuilder>? masaBalazorAction = default)
2120
{
2221
ArgumentNullException.ThrowIfNull(projectName);
2322
ArgumentNullException.ThrowIfNull(otlpUrl);
2423
ArgumentNullException.ThrowIfNull(serviceVersion);
2524
ArgumentNullException.ThrowIfNull(projectName);
26-
AddMasaStackComponentsService(services, project, i18nDirectoryPath, authHost, mcHost, pmHost, serviceVersion, microFrontend: microFrontend);
25+
AddMasaStackComponentsService(services, project, i18nDirectoryPath, authHost, mcHost, pmHost, serviceVersion, microFrontend, masaBalazorAction);
2726
AddObservable(services, false, project: project, serviceVersion: serviceVersion, projectName: projectName, otlpUrl: otlpUrl);
2827
return services;
2928
}
3029

3130
private static void AddMasaStackComponentsService(IServiceCollection services, MasaStackProject project,
3231
string? i18nDirectoryPath = "wwwroot/i18n",
33-
string? authHost = null, string? mcHost = null, string? pmHost = null, string? serviceVersion = null, bool microFrontend = false)
32+
string? authHost = null, string? mcHost = null, string? pmHost = null, string? serviceVersion = null, bool microFrontend = false,
33+
Action<IMasaBlazorBuilder>? masaBalazorAction = default)
3434
{
3535
services.TryAddScoped<CookieStorage>();
3636
services.TryAddScoped<LocalStorage>();
@@ -129,6 +129,8 @@ private static void AddMasaStackComponentsService(IServiceCollection services, M
129129
{
130130
masaBuilder.AddI18nForWasmAsync(i18nDirectoryPath);
131131
}
132+
133+
masaBalazorAction?.Invoke(masaBuilder);
132134
}
133135

134136
private static void AddObservable(IServiceCollection services, bool isMasa, MasaStackProject project, string? serviceVersion = null, string? projectName = null, string? otlpUrl = null)
Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
global using FluentValidation;
2-
global using IdentityModel.Client;
32
global using Mapster;
43
global using Masa.Blazor;
4+
global using Masa.Blazor.Core;
5+
global using Masa.Blazor.Core.I18n;
56
global using Masa.Blazor.Presets;
67
global using Masa.BuildingBlocks.Authentication.Identity;
7-
global using Masa.BuildingBlocks.Configuration;
88
global using Masa.BuildingBlocks.StackSdks.Auth;
99
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts;
10-
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts.Consts;
1110
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts.Enum;
1211
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model;
1312
global using Masa.BuildingBlocks.StackSdks.Config;
14-
global using Masa.BuildingBlocks.StackSdks.Isolation;
13+
global using Masa.BuildingBlocks.StackSdks.Config.Consts;
14+
global using Masa.BuildingBlocks.StackSdks.Dcc;
1515
global using Masa.BuildingBlocks.StackSdks.Mc.Enum;
1616
global using Masa.BuildingBlocks.StackSdks.Mc.Model;
1717
global using Masa.BuildingBlocks.StackSdks.Pm;
18+
global using Masa.Contrib.Authentication.Identity.Core;
1819
global using Masa.Contrib.StackSdks.Caller;
1920
global using Masa.Contrib.StackSdks.Config;
20-
global using Masa.Contrib.StackSdks.Isolation;
21+
global using Masa.Contrib.StackSdks.Dcc;
2122
global using Masa.Stack.Components.Configs;
2223
global using Masa.Stack.Components.Extensions;
23-
global using Masa.Stack.Components.Extensions.OpenIdConnect;
2424
global using Masa.Stack.Components.Infrastructure;
2525
global using Masa.Stack.Components.Infrastructure.Identity;
2626
global using Masa.Stack.Components.Layouts;
@@ -29,17 +29,19 @@
2929
global using Masa.Stack.Components.Options;
3030
global using Masa.Stack.Components.Shared.GlobalNavigations;
3131
global using Masa.Stack.Components.Store;
32-
global using Masa.Stack.Components.TaskHandle;
33-
global using Masa.Stack.Components.UserCenters.Models;
34-
global using Microsoft.AspNetCore.Authorization;
3532
global using Microsoft.AspNetCore.Components;
33+
global using Microsoft.AspNetCore.Components.Authorization;
3634
global using Microsoft.AspNetCore.Components.Forms;
3735
global using Microsoft.AspNetCore.Components.Rendering;
3836
global using Microsoft.AspNetCore.Components.Routing;
3937
global using Microsoft.AspNetCore.Components.Web;
38+
global using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
39+
global using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
40+
global using Microsoft.AspNetCore.SignalR.Client;
41+
global using Microsoft.Extensions.Caching.Memory;
4042
global using Microsoft.Extensions.Configuration;
4143
global using Microsoft.Extensions.DependencyInjection;
42-
global using Microsoft.AspNetCore.SignalR.Client;
44+
global using Microsoft.Extensions.DependencyInjection.Extensions;
4345
global using Microsoft.Extensions.Logging;
4446
global using Microsoft.JSInterop;
4547
global using System.Collections.Concurrent;
@@ -48,24 +50,10 @@
4850
global using System.Diagnostics.CodeAnalysis;
4951
global using System.Globalization;
5052
global using System.Linq.Expressions;
53+
global using System.Reflection;
5154
global using System.Runtime.CompilerServices;
5255
global using System.Security.Claims;
5356
global using System.Text;
5457
global using System.Text.Json;
55-
global using System.Text.Json.Nodes;
5658
global using System.Text.Json.Serialization;
5759
global using System.Text.RegularExpressions;
58-
global using Masa.Blazor.Core;
59-
global using Masa.Stack.Components.Standalone;
60-
global using Masa.Blazor.Core.I18n;
61-
global using Masa.BuildingBlocks.StackSdks.Config.Consts;
62-
global using Microsoft.AspNetCore.Components.Authorization;
63-
global using Masa.BuildingBlocks.StackSdks.Dcc;
64-
global using Masa.Utils.Caching.Memory;
65-
global using Microsoft.Extensions.Caching.Memory;
66-
global using Masa.BuildingBlocks.Isolation;
67-
global using Masa.Contrib.Authentication.Identity.Core;
68-
global using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
69-
global using Microsoft.Extensions.DependencyInjection.Extensions;
70-
global using Masa.Contrib.StackSdks.Dcc;
71-
global using System.Reflection;

0 commit comments

Comments
 (0)