Skip to content

Commit

Permalink
Merge pull request #40 from pardahlman/issue/#39
Browse files Browse the repository at this point in the history
Introduce non-generic interface IBusClient
  • Loading branch information
pardahlman authored and pardahlman committed Feb 10, 2016
2 parents 278c519 + 516f046 commit 92a79f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/RawRabbit.vNext/BusClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,39 @@ namespace RawRabbit.vNext
{
public class BusClientFactory
{
public static BusClient CreateDefault(TimeSpan requestTimeout)
public static IBusClient CreateDefault(TimeSpan requestTimeout)
{
var cfg = RawRabbitConfiguration.Local;
cfg.RequestTimeout = requestTimeout;
return CreateDefault(cfg);
}

public static BusClient CreateDefault(RawRabbitConfiguration config)
public static IBusClient CreateDefault(RawRabbitConfiguration config)
{
var addCfg = new Action<IServiceCollection>(s => s.AddSingleton(p => config));
var services = new ServiceCollection().AddRawRabbit(null, addCfg);
return CreateDefault(services);
}

public static BusClient CreateDefault(Action<IServiceCollection> custom = null)
public static IBusClient CreateDefault(Action<IServiceCollection> custom = null)
{
var services = new ServiceCollection().AddRawRabbit(null, custom);
return CreateDefault(services);
}

public static BusClient CreateDefault(Action<IConfigurationBuilder> config, Action<IServiceCollection> custom)
public static IBusClient CreateDefault(Action<IConfigurationBuilder> config, Action<IServiceCollection> custom)
{
var services = new ServiceCollection().AddRawRabbit(config, custom);
return CreateDefault(services);
}

public static BusClient CreateDefault(IServiceCollection services)
public static IBusClient CreateDefault(IServiceCollection services)
{
var serviceProvider = services.BuildServiceProvider();

LogManager.CurrentFactory = serviceProvider.GetService<ILoggerFactory>();

return serviceProvider.GetService<BusClient>();
return serviceProvider.GetService<IBusClient>();
}

public static IBusClient<TMessageContext> CreateDefault<TMessageContext>(Action<IConfigurationBuilder> config = null, Action<IServiceCollection> custom = null) where TMessageContext : IMessageContext
Expand Down
2 changes: 1 addition & 1 deletion src/RawRabbit.vNext/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class IServiceCollectionExtensions
public static IServiceCollection AddRawRabbit(this IServiceCollection collection, Action<IConfigurationBuilder> config = null, Action<IServiceCollection> custom = null)
{
return collection
.AddTransient<BusClient>()
.AddTransient<IBusClient,BusClient>()
.AddRawRabbit<MessageContext>(config, custom);
}

Expand Down
4 changes: 3 additions & 1 deletion src/RawRabbit/BusClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace RawRabbit
{
public class BusClient : BaseBusClient<MessageContext>
public interface IBusClient : IBusClient<MessageContext> { }

public class BusClient : BaseBusClient<MessageContext>, IBusClient
{
public BusClient(IConfigurationEvaluator configEval, ISubscriber<MessageContext> subscriber, IPublisher publisher, IResponder<MessageContext> responder, IRequester requester)
: base(configEval, subscriber, publisher, responder, requester)
Expand Down

0 comments on commit 92a79f3

Please sign in to comment.