Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
using System;
using System.Configuration;
using NServiceBus.Config;
using NServiceBus.Config.ConfigurationSource;
namespace NServiceBus
{
public class UserConfigurationSource : IConfigurationSource
{
readonly Action<UnicastBusConfig> UnicastCallback;
readonly Action<MsmqTransportConfig> MsmqTransportCallback;
public UserConfigurationSource()
: this(null, null)
{
}
public UserConfigurationSource(Action<UnicastBusConfig> unicastCallback)
: this(unicastCallback, null)
{
}
public UserConfigurationSource(Action<MsmqTransportConfig> msmqTransportCallback)
: this(null, msmqTransportCallback)
{
}
public UserConfigurationSource(Action<UnicastBusConfig> unicastCallback, Action<MsmqTransportConfig> msmqTransportCallback)
{
this.UnicastCallback = unicastCallback;
this.MsmqTransportCallback = msmqTransportCallback;
}
public T GetConfiguration<T>() where T : class
{
if (typeof(T) == typeof(MsmqSubscriptionStorageConfig))
return ConfigurationManager.GetSection(typeof(T).Name) as T;
if (typeof(T) == typeof(DBSubscriptionStorageConfig))
return ConfigurationManager.GetSection(typeof(T).Name) as T;
if (typeof(T) == typeof(MsmqTransportConfig) && MsmqTransportCallback != null)
return MsmqTransportConfiguration() as T;
if (typeof(T) == typeof(UnicastBusConfig) && UnicastCallback != null)
return UnicastBusConfiguration() as T;
return ConfigurationManager.GetSection(typeof(T).Name) as T;
}
private UnicastBusConfig UnicastBusConfiguration()
{
var config = new UnicastBusConfig();
UnicastCallback(config);
return config;
}
private MsmqTransportConfig MsmqTransportConfiguration()
{
var config = new MsmqTransportConfig();
MsmqTransportCallback(config);
return config;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.