using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using System.Application.Services;
using System.Application.Services.Implementation;
using System.Application.Services.Implementation.Permissions;
using System.Diagnostics;
using System.Logging;
using MSEXOptions = Microsoft.Extensions.Options.Options;
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
///
/// 尝试添加配置项
///
///
///
///
///
public static IServiceCollection TryAddOptions(this IServiceCollection services, TOptions options) where TOptions : class, new()
{
services.TryAddSingleton(MSEXOptions.Create(options));
return services;
}
///
/// 尝试添加适用于安卓平台的Toast
///
///
///
public static IServiceCollection TryAddToast(this IServiceCollection services)
=> PlatformToastImpl.TryAddToast(services);
///
/// 添加客户端日志提供程序
///
///
///
public static ILoggingBuilder AddClientProvider(this ILoggingBuilder builder)
{
builder.AddProvider(PlatformLoggerProvider.Instance);
return builder;
}
///
/// 添加客户端日志
///
///
///
public static IServiceCollection AddClientLogging(this IServiceCollection services)
{
services.AddLogging(l => l.AddClientProvider());
return services;
}
///
/// 添加调试模式显示
///
///
///
public static IServiceCollection TryAddDebuggerDisplay(this IServiceCollection services)
{
services.TryAddSingleton();
return services;
}
///
/// 添加电话服务
///
///
///
public static IServiceCollection AddTelephonyService(this IServiceCollection services)
{
services.AddSingleton();
return services;
}
///
/// 添加平台权限
///
///
///
public static IServiceCollection AddPlatformPermissions(this IServiceCollection services)
{
services.AddSingleton();
return services;
}
}
}