Skip to content

Commit

Permalink
Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
g0dzZz-coder committed Oct 19, 2022
1 parent 6fa1dbe commit bfbd8c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
9 changes: 3 additions & 6 deletions Random/Application/ServiceBuilder/RandomServiceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ public IRandomServiceBuilder With(Type valueType, IRandomizer randomizer)
{
Throw.RandomizerForTypeAlreadyRegistered(valueType);
}

_randomizers.Add(valueType, randomizer);

return this;
}

public RandomServiceBuilder()
{
_randomizers = new Dictionary<Type, IRandomizer>();
}
public RandomServiceBuilder() => _randomizers = new Dictionary<Type, IRandomizer>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public sealed class ConcurrentPseudoRandomizers : IRandomizerCollection
{
private static readonly SystemRandomizersMapper RANDOMIZERS_MAPPER;

public IRandomizer GetRandomizer(Type valueType) => RANDOMIZERS_MAPPER.GetRandomizer(valueType);

public IEnumerable<IRandomizer> GetAllRandomizers() => RANDOMIZERS_MAPPER.GetAllRandomizers();

static ConcurrentPseudoRandomizers()
{
var randomImpl =
Expand All @@ -28,9 +32,5 @@ static ConcurrentPseudoRandomizers()
new DoubleRandomProxy(randomImpl),
new ByteArrayRandomProxy(randomImpl));
}

public IRandomizer GetRandomizer(Type valueType) => RANDOMIZERS_MAPPER.GetRandomizer(valueType);

public IEnumerable<IRandomizer> GetAllRandomizers() => RANDOMIZERS_MAPPER.GetAllRandomizers();
}
}
8 changes: 4 additions & 4 deletions Random/Application/System/Collections/CryptoRandomizers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public sealed class CryptoRandomizers : IRandomizerCollection
{
private readonly SystemRandomizersMapper _randomizersMapper;

public IRandomizer GetRandomizer(Type valueType) => _randomizersMapper.GetRandomizer(valueType);

public IEnumerable<IRandomizer> GetAllRandomizers() => _randomizersMapper.GetAllRandomizers();

public CryptoRandomizers()
{
var random = new CryptoRandom();
Expand All @@ -23,10 +27,6 @@ public CryptoRandomizers()
new ByteArrayRandomProxy(random));
}

public IRandomizer GetRandomizer(Type valueType) => _randomizersMapper.GetRandomizer(valueType);

public IEnumerable<IRandomizer> GetAllRandomizers() => _randomizersMapper.GetAllRandomizers();

private abstract class CryptoRandomProxy : IDisposable
{
private readonly CryptoRandom _cryptoRandom;
Expand Down
8 changes: 4 additions & 4 deletions Random/Application/System/Collections/PseudoRandomizers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public sealed class PseudoRandomizers : IRandomizerCollection
{
private readonly SystemRandomizersMapper _randomizersMapper;

public IRandomizer GetRandomizer(Type valueType) => _randomizersMapper.GetRandomizer(valueType);

public IEnumerable<IRandomizer> GetAllRandomizers() => _randomizersMapper.GetAllRandomizers();

public PseudoRandomizers()
{
var random = new global::System.Random();
Expand All @@ -24,9 +28,5 @@ public PseudoRandomizers()
new DoubleRandomProxy(random),
new ByteArrayRandomProxy(random));
}

public IRandomizer GetRandomizer(Type valueType) => _randomizersMapper.GetRandomizer(valueType);

public IEnumerable<IRandomizer> GetAllRandomizers() => _randomizersMapper.GetAllRandomizers();
}
}

0 comments on commit bfbd8c0

Please sign in to comment.