Mark van Renswoude
1a0d9b2570
Changed BindingFilters to MessageFilterMiddleware (in preparation for SignalR interaction package) Start of SqlConnectionFlowRepository
37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
|
|
namespace Tapeti
|
|
{
|
|
public class TapetiAppSettingsConnectionParams : TapetiConnectionParams
|
|
{
|
|
public const string DefaultPrefix = "rabbitmq:";
|
|
public const string KeyHostname = "hostname";
|
|
public const string KeyPort = "port";
|
|
public const string KeyVirtualHost = "virtualhost";
|
|
public const string KeyUsername = "username";
|
|
public const string KeyPassword = "password";
|
|
public const string KeyPrefetchCount = "prefetchcount";
|
|
|
|
|
|
public TapetiAppSettingsConnectionParams(string prefix = DefaultPrefix)
|
|
{
|
|
var keys = ConfigurationManager.AppSettings.AllKeys;
|
|
Action<string, Action<string>> getAppSetting = (key, setValue) =>
|
|
{
|
|
if (keys.Contains(prefix + key))
|
|
setValue(ConfigurationManager.AppSettings[prefix + key]);
|
|
};
|
|
|
|
|
|
getAppSetting(KeyHostname, value => HostName = value);
|
|
getAppSetting(KeyPort, value => Port = int.Parse(value));
|
|
getAppSetting(KeyVirtualHost, value => VirtualHost = value);
|
|
getAppSetting(KeyUsername, value => Username = value);
|
|
getAppSetting(KeyPassword, value => Password = value);
|
|
getAppSetting(KeyPrefetchCount, value => PrefetchCount = ushort.Parse(value));
|
|
}
|
|
}
|
|
}
|