@@ -11,7 +11,7 @@ footer: 'https://chris-ayers.com'
1111
1212## Chris Ayers
1313
14- ![ bg right:40 %] ( ./img/dotnet-logo.png )
14+ ![ bg right:50 %] ( ./img/dotnet-logo.png )
1515
1616---
1717
@@ -590,6 +590,8 @@ public class FileOptions
590590
591591---
592592
593+ <!-- _class: full-width -->
594+
593595# Types of IOptions
594596
595597| | Singleton | Reloading Support | Named Option Support |
@@ -732,8 +734,6 @@ public class DatabaseOptions
732734 [RegularExpression (@" ^[a-zA-Z0-9_]+$" )]
733735 public string DatabaseName { get ; set ; } = " " ;
734736}
735-
736- // Register with validation
737737services .AddOptions <DatabaseOptions >()
738738 .Bind (configuration .GetSection (" Database" ))
739739 .ValidateDataAnnotations ()
@@ -753,11 +753,9 @@ public class DatabaseOptionsValidator : IValidateOptions<DatabaseOptions>
753753 var failures = new List <string >();
754754
755755 if (string .IsNullOrEmpty (options .ConnectionString ))
756- failures .Add (" ConnectionString is required" );
757-
756+ failures .Add (" ConnectionString is required" );
758757 if (options .CommandTimeoutSeconds <= 0 )
759758 failures .Add (" CommandTimeoutSeconds must be positive" );
760-
761759 if (! IsValidDatabaseName (options .DatabaseName ))
762760 failures .Add (" Invalid database name format" );
763761
@@ -814,13 +812,11 @@ var app = builder.Build();
814812- ** Better DevEx** : Immediate feedback during development
815813
816814``` csharp
817- // Custom validation method
818815services .AddOptions <MyOptions >()
819816 .Bind (configuration .GetSection (" MySection" ))
820817 .Validate (options =>
821- {
822- return options .ApiKey ? .Length >= 10 ;
823- }, " ApiKey must be at least 10 characters" )
818+ { return options .ApiKey ? .Length >= 10 ; },
819+ " ApiKey must be at least 10 characters" )
824820 .ValidateOnStart ();
825821```
826822
0 commit comments