about summary refs log tree commit diff
path: root/LibMatrix/Services/ServiceInstaller.cs
blob: 5ffd43a5c546e55f4823ddafd27622c29ac77bec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using LibMatrix.Services.WellKnownResolver;
using LibMatrix.Services.WellKnownResolver.WellKnownResolvers;
using Microsoft.Extensions.DependencyInjection;

namespace LibMatrix.Services;

public static class ServiceInstaller {
    public static IServiceCollection AddRoryLibMatrixServices(this IServiceCollection services, RoryLibMatrixConfiguration? config = null) {
        //Add config
        services.AddSingleton(config ?? new RoryLibMatrixConfiguration());

        //Add services
        services.AddSingleton<ClientWellKnownResolver>();
        services.AddSingleton<ServerWellKnownResolver>();
        services.AddSingleton<SupportWellKnownResolver>();
        if (!services.Any(x => x.ServiceType == typeof(WellKnownResolverConfiguration)))
            services.AddSingleton<WellKnownResolverConfiguration>();
        services.AddSingleton<WellKnownResolverService>();
        // Legacy
        services.AddSingleton<HomeserverResolverService>();
        services.AddSingleton<HomeserverProviderService>();

        return services;
    }
}

public class RoryLibMatrixConfiguration {
    public string AppName { get; set; } = "Rory&::LibMatrix";
}