开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜