// ******************************************************************* // Public methods. // ******************************************************************* #region Public methods /// <summary> /// This method adds AWS repositories for the CG.Secrets library. /// </summary> /// <param name="serviceCollection">The service collection to use for /// the operation.</param> /// <param name="configuration">The configuration to use for the operation.</param> /// <param name="serviceLifetime">The service lifetime to use for the operation.</param> /// <returns>The value of the <paramref name="serviceCollection"/> parameter, /// for chaining calls together.</returns> public static IServiceCollection AddAwsRepositories( this IServiceCollection serviceCollection, IConfiguration configuration, ServiceLifetime serviceLifetime = ServiceLifetime.Scoped ) { // Call the overload with the default data protector. return(serviceCollection.AddAwsRepositories( DataProtector.Instance(), configuration, serviceLifetime )); }
static void Main(string[] args) { var options = new TestOptions() { A = "secret 1", B = "secret 2", C = "secret 3" }; // Example: Protect any decorated property values. DataProtector.Instance().ProtectProperties(options); // Notice that we never touched the non-decorated property. Console.WriteLine($"property A is: {options.A}"); // Notice that we protected the decorated property. Console.WriteLine($"property B is: {options.B}"); // Notice that we protected the decorated property. Console.WriteLine($"property C is: {options.C}"); // Let's unprotect C, to demonstrate the 'optional' feature. options.C = "plain text secret"; // Example: Unprotect any protected properties. DataProtector.Instance().UnprotectProperties(options); // Notice that we never touched the non-decorated property. Console.WriteLine($"property A is: {options.A}"); // Notice that we unprotected the decorated property. Console.WriteLine($"property B is: {options.B}"); // Notice that we the optional property, since it held plain text. Console.WriteLine($"property C is: {options.C}"); // We're done! Console.WriteLine("Done - press any key to exit"); Console.ReadKey(); }