1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using EasyDevCore.Common.Security;
- using Microsoft.Extensions.Configuration;
- namespace EasyDevCore.Configuration
- {
- /// <summary>
- ///
- /// </summary>
- /// <seealso cref="Microsoft.Extensions.Configuration.IConfigurationSource" />
- public class ProtectDataConfigurationSource : IConfigurationSource
- {
- private readonly IConfigurationRoot _configurationRoot;
- /// <summary>
- /// The decrypt function
- /// </summary>
- private readonly Func<string, string, string> _decryptFunc;
- private readonly Func<string, string, string> _encryptFunc;
- /// <summary>
- /// Initializes a new instance of the <see cref="ProtectDataConfigurationSource" /> class.
- /// </summary>
- /// <param name="configurationRoot">The configuration root.</param>
- /// <param name="decryptFunc">The decrypt function.</param>
- /// <param name="encryptFunc">The encrypt function.</param>
- public ProtectDataConfigurationSource(IConfigurationRoot configurationRoot, Func<string, string, string> encryptFunc, Func<string, string, string> decryptFunc)
- {
- _configurationRoot = configurationRoot;
- _decryptFunc = decryptFunc;
- _encryptFunc = encryptFunc;
- }
- /// <summary>
- /// Builds the <see cref="T:Microsoft.Extensions.Configuration.IConfigurationProvider" /> for this source.
- /// </summary>
- /// <param name="builder">The <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder" />.</param>
- /// <returns>
- /// An <see cref="T:Microsoft.Extensions.Configuration.IConfigurationProvider" />
- /// </returns>
- public IConfigurationProvider Build(IConfigurationBuilder builder)
- {
- return new ProtectDataConfigurationProvider(_configurationRoot, _decryptFunc, _encryptFunc);
- }
- }
- }
|