using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Application.Services;
using System.Application.Services.Implementation;
using System.Security;
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;
}
///
/// 添加由 Xamarin.Essentials.SecureStorage 或 Repository 实现的
///
///
///
public static IServiceCollection TryAddStorage(this IServiceCollection services)
{
if (DI.DeviceIdiom == DeviceIdiom.Desktop)
{
services.TryAddSingleton();
}
else
{
services.TryAddSingleton();
}
return services;
}
///
/// 添加运行时权限
///
///
///
public static IServiceCollection TryAddPermissions(this IServiceCollection services)
{
services.TryAddSingleton();
return services;
}
}
}