public static void ConfigureServices(IServiceCollection services)
        {
            services.AddLogging(l => l.AddProvider(NUnitLoggerProvider.Instance));
            services.Configure <LoggerFilterOptions>(o =>
            {
                o.MinLevel = LogLevel.Trace;
            });

            var options = new AppSettings
            {
                ApiBaseUrl = "https://localhost:5001",
                //AppVersion = Guid.ParseExact(DevAppVersion, "N"),
                RSASecret = DevRSAPublicKey,
            };

            // app 配置项
            services.TryAddOptions(options);

            // 添加安全服务
            services.AddSecurityService <EmbeddedAesDataProtectionProvider, EmptyLocalDataProtectionProvider>();

            // 模型验证框架
            services.TryAddModelValidator();

            services.AddRepositories();

            // 键值对存储
            services.TryAddSecureStorage();

            // 业务平台用户管理
            services.TryAddUserManager();

            services.TryAddClientHttpPlatformHelperService();

            // 服务端API调用
            services.TryAddCloudServiceClient <CloudServiceClient>(c =>
            {
#if NETCOREAPP3_0_OR_GREATER
                c.DefaultRequestVersion = HttpVersion.Version20;
#endif
#if NET5_0_OR_GREATER
                c.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher;
#endif
            }, configureHandler:
#if NETCOREAPP2_1_OR_GREATER
                                                                   () => new SocketsHttpHandler
            {
                UseCookies             = false,
                AutomaticDecompression = DecompressionMethods.GZip,
            }
#else
                                                                   null
#endif
                                                                   );

            // 通用 Http 服务
            services.AddHttpService();

            PlatformToastImpl.TryAddToast(services);
        }
Beispiel #2
0
        static void ConfigureServices(IServiceCollection services)
        {
            services.AddLogging(l => l.AddProvider(NUnitLoggerProvider.Instance));
            services.Configure <LoggerFilterOptions>(o =>
            {
                o.MinLevel = LogLevel.Trace;
            });

            var options = new AppSettings
            {
                ApiBaseUrl = "https://localhost:5001",
                AppVersion = Guid.ParseExact(DevAppVersion, "N"),
                RSASecret  = DevRSAPublicKey,
            };

            // app 配置项
            services.TryAddOptions(options);

            // 添加安全服务
            services.AddSecurityService <EmbeddedAesDataProtectionProvider, EmptyLocalDataProtectionProvider>();

            // 模型验证框架
            services.TryAddModelValidator();

            services.AddRepositories();

            // 键值对存储
            services.TryAddStorage();

            // 业务平台用户管理
            services.TryAddUserManager();

            services.AddDesktopHttpPlatformHelper();

            // 服务端API调用
            services.TryAddCloudServiceClient <CloudServiceClient>();

            // 通用 Http 服务
            services.AddHttpService();

            PlatformToastImpl.TryAddToast(services);
        }