Exemple #1
0
        /// <summary>
        /// Adds default Data Protection services to an <see cref="IServiceCollection"/>.
        /// </summary>
        /// <param name="services">The service collection to which to add DataProtection services.</param>
        /// <returns>The <paramref name="services"/> instance.</returns>
        public static IServiceCollection AddDataProtection(this IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddOptions();
            services.TryAdd(DataProtectionServices.GetDefaultServices());
            return(services);
        }
Exemple #2
0
        /// <summary>
        /// Adds data protection services to the specified <see cref="IServiceCollection" />.
        /// </summary>
        /// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
        public static IDataProtectionBuilder AddDataProtection(this IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddSingleton <IActivator, RC1ForwardingActivator>();
            services.AddOptions();
            services.TryAdd(DataProtectionServices.GetDefaultServices());

            return(new DataProtectionBuilder(services));
        }