init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using Kreta.Core.MessageBroker.Azure.EventHub.Client.Configuration;
|
||||
|
||||
namespace Kreta.MessageBroker.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Message client configuration section
|
||||
/// </summary>
|
||||
public class MessageBrokerConfigurationSection : ConfigurationSection, IMessageBrokerConfiguration, IAzureEventHubClientsConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of section
|
||||
/// </summary>
|
||||
const string SectionName = "MessageBroker";
|
||||
|
||||
/// <summary>
|
||||
/// The instance
|
||||
/// </summary>
|
||||
static Lazy<MessageBrokerConfigurationSection> instance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The instance.
|
||||
/// </value>
|
||||
public static MessageBrokerConfigurationSection Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return instance.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clients
|
||||
/// </summary>
|
||||
[ConfigurationProperty(nameof(Clients))]
|
||||
[ConfigurationCollection(typeof(MessageClientConfigurationElement))]
|
||||
public MessageClientConfigurationElementCollection Clients
|
||||
{
|
||||
get
|
||||
{
|
||||
return (MessageClientConfigurationElementCollection)base[nameof(Clients)];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clients
|
||||
/// </summary>
|
||||
[ConfigurationProperty(nameof(EventHubs))]
|
||||
[ConfigurationCollection(typeof(EventHubClientConfigurationElement))]
|
||||
public EventHubClientConfigurationElementCollection EventHubs
|
||||
{
|
||||
get
|
||||
{
|
||||
return (EventHubClientConfigurationElementCollection)base[nameof(EventHubs)];
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<IAzureEventHubClientConfiguration> IAzureEventHubClientsConfiguration.EventHubs => this.EventHubs;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MessageBrokerConfigurationSection"/> class.
|
||||
/// </summary>
|
||||
static MessageBrokerConfigurationSection()
|
||||
{
|
||||
instance = new Lazy<MessageBrokerConfigurationSection>(() =>
|
||||
{
|
||||
var section = (MessageBrokerConfigurationSection)ConfigurationManager.GetSection(SectionName);
|
||||
|
||||
if (section == null)
|
||||
{
|
||||
throw new ConfigurationErrorsException($"{SectionName} configuration section was not found");
|
||||
}
|
||||
|
||||
return section;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue