kreta/Kreta.MessageBroker/Configuration/EventHubClientConfigurationElementCollection.cs
2024-03-13 00:33:46 +01:00

66 lines
2 KiB
C#

using System.Collections.Generic;
using System.Configuration;
using Kreta.Core.MessageBroker.Azure.EventHub.Client.Configuration;
namespace Kreta.MessageBroker.Configuration
{
public class EventHubClientConfigurationElementCollection : ConfigurationElementCollection, IEnumerable<IAzureEventHubClientConfiguration>
{
#region [Properties]
/// <summary>
/// Collection type
/// </summary>
public override ConfigurationElementCollectionType CollectionType
{
get { return ConfigurationElementCollectionType.BasicMap; }
}
/// <summary>
/// Get element name
/// </summary>
protected override string ElementName
{
get { return "EventHub"; }
}
#endregion
#region [Private/Protected Methods]
/// <summary>
/// Create new element
/// </summary>
/// <returns>Configuration element</returns>
protected override ConfigurationElement CreateNewElement()
{
return new EventHubClientConfigurationElement();
}
/// <summary>
/// Get element key
/// </summary>
/// <param name="element">Element</param>
/// <returns>Element key</returns>
protected override object GetElementKey(ConfigurationElement element)
{
return ((EventHubClientConfigurationElement)element).Name;
}
IEnumerator<IAzureEventHubClientConfiguration> IEnumerable<IAzureEventHubClientConfiguration>.GetEnumerator()
{
var enumerator = base.GetEnumerator();
var eventHubClientConfiguration = new List<IAzureEventHubClientConfiguration>();
while (enumerator.MoveNext())
{
eventHubClientConfiguration.Add((IAzureEventHubClientConfiguration)enumerator.Current);
}
return eventHubClientConfiguration.GetEnumerator();
}
#endregion
}
}