本文整理汇总了C#中IConfig.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IConfig.GetAttribute方法的具体用法?C# IConfig.GetAttribute怎么用?C# IConfig.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfig
的用法示例。
在下文中一共展示了IConfig.GetAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
private ILogManager Create(IConfig config) {
var typeName = config.GetAttribute(ConfigSection, QualifiedNameAttribute);
var manager = Create(typeName) as ILogManager;
if(manager == null) {
throw new TypeLoadException(string.Format("Type '{0}' is not an instance of '{1}'", typeName, typeof(ILogManager).FullName));
}
return manager;
}
示例2: GetFormatter
internal static IFormatter GetFormatter(IConfig config) {
var formatters = new CompositeFormatter();
string[] patterns = config.GetAttributeArray(".", "rule", "pattern");
foreach(string pattern in patterns) {
string replacement = config.GetAttribute(".", string.Format("rule[@pattern='{0}']", pattern), "replacement");
bool caseSensitive = false;
if(config.ContainsAttribute(".", string.Format("rule[@pattern='{0}']", pattern), "caseSensitive")) {
caseSensitive = config.GetAttribute<bool>(".", string.Format("rule[@pattern='{0}']", pattern), "caseSensitive");
}
var rule = new Rule(pattern, replacement, caseSensitive);
var ruleFormatter = new RegexFormatter(rule);
formatters.Add(ruleFormatter);
}
return formatters;
}
示例3: SetAttributeDefinitionList
private static void SetAttributeDefinitionList(IConfig configSection, UsersConfig users) {
var containsCustomAttributes = configSection.ContainsKey("users", "attributes");
var attributes = new List<IAttributeDefinition>(users.Attributes);
if(containsCustomAttributes) {
attributes.Clear();
}
attributes.Attach(users.EmailAttribute, true);
attributes.Attach(users.CreationDateAttribute, true);
attributes.Attach(users.LastLoginDateAttribute, true);
attributes.Attach(users.LastPasswordChangedDateAttribute, true);
attributes.Attach(users.DescriptionAttribute, true);
attributes.Attach(users.MembershipAttribute, true);
if(containsCustomAttributes) {
var attributeValues = configSection.GetValueArray("users/attributes", "attribute");
foreach(var attribute in attributeValues) {
var excludeFromNameSearch = false;
var attributeKey = String.Format("users/attributes/attribute[@value='{0}']", attribute);
if(configSection.ContainsAttribute(attributeKey, "excludeFromNameSearch")) {
excludeFromNameSearch = configSection.GetAttribute<bool>(attributeKey, "excludeFromNameSearch");
}
attributes.Attach(attribute, excludeFromNameSearch);
}
}
users.Attributes = attributes;
}
示例4: GetPredefinedContextAttribute
private static string GetPredefinedContextAttribute(string property, IConfig config) {
string result = null;
if(config.ContainsAttribute("predefinedProperties", property, "context")) {
result = config.GetAttribute("predefinedProperties", property, "context");
}
return result;
}
示例5: SetAttributeDefinitionList
private static void SetAttributeDefinitionList(IConfig configSection, GroupsConfig groups) {
var containsCustomAttributes = configSection.ContainsKey("groups", "attributes");
var attributes = new List<IAttributeDefinition>(groups.Attributes);
if(containsCustomAttributes) {
attributes.Clear();
}
attributes.Attach(groups.MembershipAttribute, true);
if(containsCustomAttributes) {
var attributeValues = configSection.GetValueArray("groups/attributes", "attribute");
foreach(var attribute in attributeValues) {
var excludeFromNameSearch = false;
var attributeKey = String.Format("groups/attributes/attribute[@value='{0}']", attribute);
if(configSection.ContainsAttribute(attributeKey, "excludeFromNameSearch")) {
excludeFromNameSearch = configSection.GetAttribute<bool>(attributeKey, "excludeFromNameSearch");
}
attributes.Attach(attribute, excludeFromNameSearch);
}
}
groups.Attributes = attributes;
}