1
namespace Org
.Lwes
.Config
4 using System
.Collections
.Generic
;
5 using System
.Configuration
;
9 public abstract class AbstractConfigurationElementCollection
<TElement
, TKey
> : ConfigurationElementCollection
10 where TElement
: ConfigurationElement
, new()
14 protected AbstractConfigurationElementCollection()
18 protected AbstractConfigurationElementCollection(string addElmName
20 , string removeElmName
)
22 base.AddElementName
= addElmName
;
23 base.ClearElementName
= clearElmName
;
24 base.RemoveElementName
= removeElmName
;
27 #endregion Constructors
31 public override ConfigurationElementCollectionType CollectionType
33 get { return ConfigurationElementCollectionType.AddRemoveClearMap; }
38 get { return base.Count; }
45 public TElement
this[int index
]
47 get { return (TElement)BaseGet(index); }
50 if (BaseGet(index
) != null)
54 BaseAdd(index
, value);
58 public TElement
this[TKey key
]
60 get { return (TElement)BaseGet(key); }
67 public void Add(TElement item
)
77 public int IndexOf(TElement item
)
79 return BaseIndexOf(item
);
82 public void Remove(TElement item
)
84 BaseRemove(GetElementKey(item
));
87 public void Remove(TKey key
)
92 public void RemoveAt(int index
)
97 protected override void BaseAdd(ConfigurationElement element
)
99 BaseAdd(element
, false);
102 protected override ConfigurationElement
CreateNewElement()
104 return new TElement();
107 protected override object GetElementKey(ConfigurationElement element
)
109 return PerformGetElementKey((TElement
)element
);
112 protected abstract TKey
PerformGetElementKey(TElement element
);