У меня есть раздел конфигурации, читающий из файла конфигурации. xml выглядит так
<GroupBySection>
<Groups>
<Group name="Source" product="Product One">
<Items>
<Item name="2003" type="radio" />
<Item name="2007" type="radio" />
<Item name="2010" type="radio" />
<Item name="2013" type="radio" />
<Item name="o365" type="radio" />
</Items>
</Group>
<Group name="Target" product="Product One">
<Items>
<Item name="2003" type="radio" />
<Item name="2007" type="radio" />
<Item name="2010" type="radio" />
<Item name="2013" type="radio" />
<Item name="o365" type="radio" />
</Items>
</Group>
<Group name="Source" product="Product Two">
<Items>
<Item name="2003" type="radio" />
<Item name="2007" type="radio" />
<Item name="2010" type="radio" />
<Item name="2013" type="radio" />
<Item name="o365" type="radio" />
</Items>
</Group>
</Groups>
</GroupBySection>
Когда я вызываю этот раздел конфигурации и делаю подсчет, я вижу только первые результаты Product One. Продукт 2 не отображается, потому что имя также «Источник». Я хочу, чтобы он отображал их все независимо от того, совпадает ли имя. Короче говоря, он не вернет ничего с тем же именем, с которым он уже сталкивался, хотя я этого хочу. Может ли кто-нибудь указать, что я сделал неправильно?
Код ниже
Раздел конфигурации
public class GroupByConfiguration : ConfigurationSection
{
[ConfigurationProperty("Groups")]
public GroupByElementCollection Groups
{
get { return ((GroupByElementCollection)(base["Groups"])); }
set { base["Groups"] = value; }
}
}
Раздел элемента
public class GroupByElement : ConfigurationElement
{
// Group Attributes
[ConfigurationProperty("name", IsRequired = true)]
public string Name
{
get { return (string)base["name"]; }
}
[ConfigurationProperty("product", IsRequired = true)]
public string Product
{
get { return (string)base["product"]; }
}
[ConfigurationProperty("Items")]
public ItemElementCollection Items
{
get { return ((ItemElementCollection)(base["Items"])); }
set { base["Items"] = value; }
}
}
Коллекция элементов
[ConfigurationCollection(typeof(GroupByElement))]
public class GroupByElementCollection : ConfigurationElementCollection
{
internal const string PropertyName = "Group";
public override ConfigurationElementCollectionType CollectionType
{
get
{
return ConfigurationElementCollectionType.BasicMapAlternate;
}
}
protected override string ElementName
{
get
{
return PropertyName;
}
}
protected override bool IsElementName(string elementName)
{
return elementName.Equals(PropertyName, StringComparison.InvariantCultureIgnoreCase);
}
public override bool IsReadOnly()
{
return false;
}
protected override ConfigurationElement CreateNewElement()
{
return new GroupByElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((GroupByElement)(element)).Name;
}
public GroupByElement this[int idx]
{
get { return (GroupByElement)BaseGet(idx); }
}
}
Я уверен, что это что-то глупое :) Заранее спасибо!