Enterprise Library Security Block
Does anyone know if there is a way to create the security configuration section via the Enterprise Library API or do we have to use the config wizard 开发者_StackOverflow中文版/ edit by hand?
Yes, you can configure any section via the new fluent interface. Just use ConfigurationSourceBuilder. Like so:
var builder = new ConfigurationSourceBuilder();
builder.ConfigureSecurity()
.AuthorizeUsingRuleProviderNamed("MyRules")
.SpecifyRule("Rule1", "MyRuleExpression")
.CacheSecurityInCacheStoreNamed("SecCache")
.WithOptions
.UseSharedCacheManager("MyCacheManager")
.SetAsDefault();
var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current
= EnterpriseLibraryContainer.CreateDefaultContainer(configSource);
You even get IntelliSense support.
More info on MSDN
精彩评论