| | 1 | | namespace Syki.Front.Configs; |
| | 2 | |
|
| | 3 | | public static class ServicesConfigs |
| | 4 | | { |
| | 5 | | public static void AddServicesConfigs(this WebAssemblyHostBuilder builder) |
| | 6 | | { |
| 0 | 7 | | builder.Services.AddServiceConfigs(typeof(IAcademicClient)); |
| 0 | 8 | | builder.Services.AddServiceConfigs(typeof(IAdmClient)); |
| 0 | 9 | | builder.Services.AddServiceConfigs(typeof(ICrossClient)); |
| 0 | 10 | | builder.Services.AddServiceConfigs(typeof(IStudentClient)); |
| 0 | 11 | | builder.Services.AddServiceConfigs(typeof(ITeacherClient)); |
| | 12 | |
|
| 0 | 13 | | builder.Services.AddScoped<ClipboardService>(); |
| 0 | 14 | | } |
| | 15 | |
|
| | 16 | | private static void AddServiceConfigs(this IServiceCollection services, Type? marker) |
| | 17 | | { |
| 0 | 18 | | var types = AppDomain.CurrentDomain.GetAssemblies() |
| 0 | 19 | | .Where(s => s.FullName.StartsWith("Front")) |
| 0 | 20 | | .SelectMany(s => s.GetTypes()) |
| 0 | 21 | | .Where(p => marker.IsAssignableFrom(p) && !p.IsInterface) |
| 0 | 22 | | .ToList(); |
| | 23 | |
|
| 0 | 24 | | foreach (var type in types) |
| | 25 | | { |
| 0 | 26 | | services.AddScoped(type); |
| | 27 | | } |
| 0 | 28 | | } |
| | 29 | | } |