Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace TestAllTheThings
- {
- public class ConfigurePattern
- {
- public void Configure(Action<SomeOptions> configureOptions)
- {
- var opts = new SomeOptions();
- opts.Fixed = true; // set a default
- configureOptions(opts);
- // do validation or additional steps
- }
- }
- public class SomeOptions
- {
- public bool Fixed { get; set; }
- public string NameThing { get; set; }
- public bool AnotherSwitch { get; set; }
- }
- public class Demo
- {
- public void Run()
- {
- var optionsPat = new ConfigurePattern();
- optionsPat.Configure(options =>
- {
- options.NameThing = "aasdasd";
- options.AnotherSwitch = true;
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement