using System; using System.Application; using System.Application.Services; using System.Application.Services.Implementation; using System.Net.Http; using System.Security.Cryptography; using System.Windows; // ReSharper disable once CheckNamespace namespace Microsoft.Extensions.DependencyInjection { public static partial class ServiceCollectionExtensions { public static IServiceCollection AddPlatformService(this IServiceCollection services, StartupOptions options) { #pragma warning disable CA1416 // 验证平台兼容性 if (OperatingSystem2.IsWindows) { services.AddSingleton(); services.AddSingleton(); services.AddSingleton(s => s.GetRequiredService()); if (options.HasSteam) { services.AddSingleton(); } if (options.HasGUI) { services.AddSingleton(); } services.AddSingleton(); services.AddSingleton(s => s.GetRequiredService()); services.AddSingleton(s => s.GetRequiredService()); if (OperatingSystem2.IsWindows10AtLeast) { services.AddSingleton(s => s.GetRequiredService()); services.AddSingleton(); } services.AddSingleton(); if (Windows10JumpListServiceImpl.IsSupported) { services.AddSingleton(); } else { services.AddSingleton(); } if (options.HasMainProcessRequired) { services.AddSingleton(typeof(NotifyIcon), NotifyIcon.ImplType); } //services.AddSingleton(); services.AddSingleton(); } else { throw new PlatformNotSupportedException(); } services.AddMSAppCenterApplicationSettings(); return services; #pragma warning restore CA1416 // 验证平台兼容性 } } }