Skip to content

Commit

Permalink
Update ChannelFactory.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
frankhaugen authored Feb 2, 2024
1 parent f3d047f commit d201fdb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Frank.Channels.DependencyInjection/ChannelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public class ChannelFactory : IChannelFactory
{
private readonly ConcurrentDictionary<string, object> _cache = new();

public Channel<T> CreateChannel<T>() where T : class => _cache.GetOrAdd(nameof(T), Value<T>) as Channel<T> ?? throw new InvalidOperationException($"{nameof(Channel<T>)} not found");
public Channel<T> CreateChannel<T>() where T : class => _cache.GetOrAdd(typeof(T).Name, Value<T>) as Channel<T> ?? throw new InvalidOperationException($"Channel<{typeof(T).Name}> not found");

private static Channel<T> Value<T>(string arg) where T : class =>
Channel.CreateUnbounded<T>(new UnboundedChannelOptions()
{
SingleReader = true,
SingleWriter = true
});
}
}

0 comments on commit d201fdb

Please sign in to comment.