// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Microsoft.AspNet.DataProtection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Internal; namespace Microsoft.Extensions.DependencyInjection { /// /// Allows registering and configuring Data Protection in the application. /// public static class DataProtectionServiceCollectionExtensions { /// /// Adds default Data Protection services to an . /// /// The service collection to which to add DataProtection services. /// The instance. public static IServiceCollection AddDataProtection([NotNull] this IServiceCollection services) { services.AddOptions(); services.TryAdd(DataProtectionServices.GetDefaultServices()); return services; } /// /// Configures the behavior of the Data Protection system. /// /// A service collection to which Data Protection has already been added. /// A callback which takes a parameter. /// This callback will be responsible for configuring the system. /// The instance. public static IServiceCollection ConfigureDataProtection([NotNull] this IServiceCollection services, [NotNull] Action configure) { configure(new DataProtectionConfiguration(services)); return services; } } }