/// <summary> /// Processes the section. /// </summary> /// <param name="sectconfigurationSectionion">The section.</param> /// <param name="configuration">The configuration.</param> /// <returns></returns> protected virtual KeyValuePair<string, IConfiguration>? ProcessSection( DirectorySearcherArgs args, IKeyGenerator keyGenerator, IIncludeConfigurationRule[] rules) { // check if we have a valid configuration section var bootstrapConfiguration = args.ConfigurationSection as IBootstrapConfiguration; if (bootstrapConfiguration != null) { string key = bootstrapConfiguration.Key; if (!string.IsNullOrWhiteSpace(key)) { // loop over the rules. if a rule fails, return null. foreach (var rule in rules) { if (!rule.Execute(args)) return null; } return new KeyValuePair<string, IConfiguration>(key, args.Configuration); } // todo: tracewarning } // let the rules determine what the kick out condition is. For that reason we should allow any config section and use the key generator. return null; }
private void CreateMockIncludeConfigurationByKeyRule() { var moqIsBootstrapConfigRule = new Mock<IIncludeConfigurationRule>(); moqIsBootstrapConfigRule.Setup(resolver => resolver.Execute(It.IsAny<DirectorySearcherArgs>())) .Returns<DirectorySearcherArgs>((ds) => { return ds.ConfigurationSection is IBootstrapConfiguration; }); isBootstrapConfigRule = moqIsBootstrapConfigRule.Object; var moqBoostrapConfigHasKeyRule = new Mock<IIncludeConfigurationRule>(); moqIsBootstrapConfigRule.Setup(resolver => resolver.Execute(It.IsAny<DirectorySearcherArgs>())) .Returns<DirectorySearcherArgs>((ds) => { var config = ds.ConfigurationSection as IBootstrapConfiguration; return config != null && string.IsNullOrWhiteSpace(config.Key); }); boostrapConfigHasKeyRule = moqBoostrapConfigHasKeyRule.Object; }