diff --git a/Sources/Falko.Talkie.Bridges.Telegram/Clients/TelegramBotApiClient.cs b/Sources/Falko.Talkie.Bridges.Telegram/Clients/TelegramBotApiClient.cs index 50a4315..2f8708c 100644 --- a/Sources/Falko.Talkie.Bridges.Telegram/Clients/TelegramBotApiClient.cs +++ b/Sources/Falko.Talkie.Bridges.Telegram/Clients/TelegramBotApiClient.cs @@ -6,7 +6,6 @@ using Talkie.Bridges.Telegram.Configurations; using Talkie.Bridges.Telegram.Models; using Talkie.Bridges.Telegram.Serialization; -using Talkie.Validations; using ClientHttpVersion = System.Net.HttpVersion; namespace Talkie.Bridges.Telegram.Clients; @@ -30,7 +29,8 @@ public sealed class TelegramBotApiClient : ITelegramBotApiClient public TelegramBotApiClient(ServerConfiguration serverConfiguration, ClientConfiguration? clientConfiguration = null) { - serverConfiguration.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(serverConfiguration); + clientConfiguration ??= new ClientConfiguration(); _useGzipCompression = clientConfiguration.UseGzipCompression; @@ -41,8 +41,8 @@ public TelegramBotApiClient(ServerConfiguration serverConfiguration, async Task ITelegramBotApiClient.SendAsync(string methodName, TRequest request, CancellationToken cancellationToken) { - methodName.ThrowIf().NullOrWhiteSpace(); - request.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(request); + ArgumentException.ThrowIfNullOrWhiteSpace(methodName); using var scopedCancellationTokenSource = CancellationTokenSource .CreateLinkedTokenSource(_globalCancellationTokenSource.Token, cancellationToken); @@ -55,14 +55,14 @@ async Task ITelegramBotApiClient.SendAsync(string me async Task ITelegramBotApiClient.SendAsync(string methodName, CancellationToken cancellationToken) { - methodName.ThrowIf().NullOrWhiteSpace(); + ArgumentException.ThrowIfNullOrWhiteSpace(methodName); using var scopedCancellationTokenSource = CancellationTokenSource .CreateLinkedTokenSource(_globalCancellationTokenSource.Token, cancellationToken); var result = await SendRepeatableRequestAsync(methodName, null, scopedCancellationTokenSource.Token); - result.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(result); return result; } @@ -70,8 +70,8 @@ async Task ITelegramBotApiClient.SendAsync(string methodName, Task ITelegramBotApiClient.SendAsync(string methodName, TRequest request, CancellationToken cancellationToken) { - methodName.ThrowIf().NullOrWhiteSpace(); - request.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(request); + ArgumentException.ThrowIfNullOrWhiteSpace(methodName); using var scopedCancellationTokenSource = CancellationTokenSource .CreateLinkedTokenSource(_globalCancellationTokenSource.Token, cancellationToken); diff --git a/Sources/Falko.Talkie.Bridges.Telegram/Clients/TelegramBotApiRequestException.cs b/Sources/Falko.Talkie.Bridges.Telegram/Clients/TelegramBotApiRequestException.cs index d99bc05..4677af6 100644 --- a/Sources/Falko.Talkie.Bridges.Telegram/Clients/TelegramBotApiRequestException.cs +++ b/Sources/Falko.Talkie.Bridges.Telegram/Clients/TelegramBotApiRequestException.cs @@ -2,7 +2,6 @@ using System.Net; using System.Text; using Talkie.Bridges.Telegram.Models; -using Talkie.Validations; namespace Talkie.Bridges.Telegram.Clients; @@ -14,8 +13,8 @@ public TelegramBotApiRequestException(ITelegramBotApiClient client, string metho IReadOnlyDictionary? parameters = null, Exception? innerException = null) : base(null, innerException) { - client.ThrowIf().Null(); - methodName.ThrowIf().NullOrWhiteSpace(); + ArgumentNullException.ThrowIfNull(client); + ArgumentException.ThrowIfNullOrWhiteSpace(methodName); Client = client; MethodName = methodName; diff --git a/Sources/Falko.Talkie.Bridges.Telegram/Models/TextOrNumber.cs b/Sources/Falko.Talkie.Bridges.Telegram/Models/TextOrNumber.cs index 223a011..ca9f154 100644 --- a/Sources/Falko.Talkie.Bridges.Telegram/Models/TextOrNumber.cs +++ b/Sources/Falko.Talkie.Bridges.Telegram/Models/TextOrNumber.cs @@ -1,6 +1,5 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; -using Talkie.Validations; namespace Talkie.Bridges.Telegram.Models; @@ -16,7 +15,7 @@ public readonly struct TextOrNumber public TextOrNumber(string text) { - text.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(text); _text = text; _containsTextOrNumber = true; diff --git a/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.AddRange.cs b/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.AddRange.cs index 07b02a2..06fe698 100644 --- a/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.AddRange.cs +++ b/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.AddRange.cs @@ -7,6 +7,9 @@ public static partial class SequenceExtensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AddRange(this ISequence sequence, IEnumerable values) { + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(values); + foreach (var value in values) { sequence.Add(value); @@ -16,6 +19,9 @@ public static void AddRange(this ISequence sequence, IEnumerable values [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AddRange(this ISequence sequence, IReadOnlyCollection values) { + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return; foreach (var value in values) @@ -27,6 +33,9 @@ public static void AddRange(this ISequence sequence, IReadOnlyCollection(this ISequence sequence, Sequence values) { + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return; foreach (var value in values) @@ -38,6 +47,9 @@ public static void AddRange(this ISequence sequence, Sequence values) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AddRange(this ISequence sequence, RemovableSequence values) { + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return; foreach (var value in values) @@ -49,6 +61,9 @@ public static void AddRange(this ISequence sequence, RemovableSequence [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AddRange(this ISequence sequence, FrozenSequence values) { + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return; foreach (var value in values) diff --git a/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ForEach.cs b/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ForEach.cs index b4b78af..2cbea42 100644 --- a/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ForEach.cs +++ b/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ForEach.cs @@ -1,5 +1,4 @@ using System.Runtime.CompilerServices; -using Talkie.Validations; namespace Talkie.Sequences; @@ -8,8 +7,8 @@ public static partial class SequenceExtensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ForEach(this IReadOnlySequence sequence, Action action) where T : notnull { - sequence.ThrowIf().Null(); - action.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(action); if (sequence.Count is 0) return; @@ -22,8 +21,8 @@ public static void ForEach(this IReadOnlySequence sequence, Action acti [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ForEach(this Sequence sequence, Action action) where T : notnull { - sequence.ThrowIf().Null(); - action.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(action); if (sequence.Count is 0) return; @@ -36,8 +35,8 @@ public static void ForEach(this Sequence sequence, Action action) where [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ForEach(this RemovableSequence sequence, Action action) where T : notnull { - sequence.ThrowIf().Null(); - action.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(action); if (sequence.Count is 0) return; @@ -50,8 +49,8 @@ public static void ForEach(this RemovableSequence sequence, Action acti [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ForEach(this FrozenSequence sequence, Action action) where T : notnull { - sequence.ThrowIf().Null(); - action.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(sequence); + ArgumentNullException.ThrowIfNull(action); if (sequence.Count is 0) return; diff --git a/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ToFrozenSequence.cs b/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ToFrozenSequence.cs index b7a0fdb..eafa6ec 100644 --- a/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ToFrozenSequence.cs +++ b/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ToFrozenSequence.cs @@ -6,6 +6,8 @@ public static partial class SequenceExtensions { public static FrozenSequence ToFrozenSequence(this IEnumerable values) { + ArgumentNullException.ThrowIfNull(values); + if (values is FrozenSequence sequence) return sequence; return new FrozenSequence(values); @@ -13,6 +15,8 @@ public static FrozenSequence ToFrozenSequence(this IEnumerable values) public static FrozenSequence ToFrozenSequence(this IReadOnlyCollection values) { + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return FrozenSequence.Empty; if (values is FrozenSequence sequence) return sequence; @@ -23,6 +27,8 @@ public static FrozenSequence ToFrozenSequence(this IReadOnlyCollection [MethodImpl(MethodImplOptions.AggressiveInlining)] public static FrozenSequence ToFrozenSequence(this FrozenSequence values) { + ArgumentNullException.ThrowIfNull(values); + return values; } } diff --git a/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ToRemovableSequence.cs b/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ToRemovableSequence.cs index dc6c3bc..6aa7971 100644 --- a/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ToRemovableSequence.cs +++ b/Sources/Falko.Talkie.Core/Sequences/SequenceExtensions.ToRemovableSequence.cs @@ -2,17 +2,21 @@ namespace Talkie.Sequences; public static partial class SequenceExtensions { - public static RemovableSequence ToRemovableSequence(this IEnumerable enumerable) where T : notnull + public static RemovableSequence ToRemovableSequence(this IEnumerable values) where T : notnull { + ArgumentNullException.ThrowIfNull(values); + var sequence = new RemovableSequence(); - sequence.AddRange(enumerable); + sequence.AddRange(values); return sequence; } public static RemovableSequence ToRemovableSequence(this IReadOnlyCollection values) where T : notnull { + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return []; var sequence = new RemovableSequence(); @@ -24,6 +28,8 @@ public static RemovableSequence ToRemovableSequence(this IReadOnlyCollecti public static RemovableSequence ToRemovableSequence(this Sequence values) where T : notnull { + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return []; var sequence = new RemovableSequence(); @@ -35,6 +41,8 @@ public static RemovableSequence ToRemovableSequence(this Sequence value public static RemovableSequence ToRemovableSequence(this RemovableSequence values) where T : notnull { + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return []; var sequence = new RemovableSequence(); @@ -46,6 +54,8 @@ public static RemovableSequence ToRemovableSequence(this RemovableSequence public static RemovableSequence ToRemovableSequence(this FrozenSequence values) where T : notnull { + ArgumentNullException.ThrowIfNull(values); + if (values.Count is 0) return []; var sequence = new RemovableSequence(); diff --git a/Sources/Falko.Talkie.Core/Validations/Throwable.cs b/Sources/Falko.Talkie.Core/Validations/Throwable.cs deleted file mode 100644 index 0ec3689..0000000 --- a/Sources/Falko.Talkie.Core/Validations/Throwable.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Talkie.Validations; - -public readonly ref struct Throwable([NotNull] T value, string? name = null) -{ - public readonly T Value = value; - - public readonly string? Name = name; -} diff --git a/Sources/Falko.Talkie.Core/Validations/ThrowableExtensions.Asserts.cs b/Sources/Falko.Talkie.Core/Validations/ThrowableExtensions.Asserts.cs deleted file mode 100644 index 15b6021..0000000 --- a/Sources/Falko.Talkie.Core/Validations/ThrowableExtensions.Asserts.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace Talkie.Validations; - -public static partial class ThrowableExtensions -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ref readonly Throwable Null(this in Throwable throwable) - { - if (throwable.Value is null) - { - throw new ArgumentNullException(throwable.Name); - } - - return ref throwable; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Throwable Disposed(this Throwable throwable) - { - if (throwable.Value) - { - throw new ObjectDisposedException(nameof(T)); - } - - return throwable; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Throwable NullOrEmpty(this Throwable throwable) - { - if (string.IsNullOrEmpty(throwable.Value)) - { - throw new ArgumentException("Value cannot be null or empty.", throwable.Name); - } - - return throwable; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Throwable NullOrWhiteSpace(this Throwable throwable) - { - if (string.IsNullOrWhiteSpace(throwable.Value)) - { - throw new ArgumentException("Value cannot be null or whitespace.", throwable.Name); - } - - return throwable; - } -} diff --git a/Sources/Falko.Talkie.Core/Validations/ThrowableExtensions.ThrowIf.cs b/Sources/Falko.Talkie.Core/Validations/ThrowableExtensions.ThrowIf.cs deleted file mode 100644 index afe9a06..0000000 --- a/Sources/Falko.Talkie.Core/Validations/ThrowableExtensions.ThrowIf.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Diagnostics.Contracts; -using System.Runtime.CompilerServices; - -namespace Talkie.Validations; - -public static partial class ThrowableExtensions -{ - [Pure, MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Throwable ThrowIf([NotNull] this T value, - [CallerArgumentExpression(nameof(value))] string? name = null) - { - return new Throwable(value, name); - } -} diff --git a/Sources/Falko.Talkie.Platforms.Telegram/Connections/TelegramSignalConnection.cs b/Sources/Falko.Talkie.Platforms.Telegram/Connections/TelegramSignalConnection.cs index 84ede1f..ba62f93 100644 --- a/Sources/Falko.Talkie.Platforms.Telegram/Connections/TelegramSignalConnection.cs +++ b/Sources/Falko.Talkie.Platforms.Telegram/Connections/TelegramSignalConnection.cs @@ -9,7 +9,6 @@ using Talkie.Models.Profiles; using Talkie.Platforms; using Talkie.Sequences; -using Talkie.Validations; namespace Talkie.Connections; @@ -23,8 +22,8 @@ public sealed class TelegramSignalConnection(ISignalFlow flow, protected override async Task WhenInitializingAsync(CancellationToken cancellationToken) { - serverConfiguration.ThrowIf().Null(); - clientConfiguration.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(serverConfiguration); + ArgumentNullException.ThrowIfNull(clientConfiguration); var client = new TelegramBotApiClient(serverConfiguration, clientConfiguration); diff --git a/Sources/Falko.Talkie.Platforms.Telegram/Controllers/MessageControllers/TelegramMessageController.cs b/Sources/Falko.Talkie.Platforms.Telegram/Controllers/MessageControllers/TelegramMessageController.cs index 3ec8747..a9138e6 100644 --- a/Sources/Falko.Talkie.Platforms.Telegram/Controllers/MessageControllers/TelegramMessageController.cs +++ b/Sources/Falko.Talkie.Platforms.Telegram/Controllers/MessageControllers/TelegramMessageController.cs @@ -8,7 +8,6 @@ using Talkie.Models.Messages.Outgoing; using Talkie.Platforms; using Talkie.Sequences; -using Talkie.Validations; namespace Talkie.Controllers.MessageControllers; @@ -20,7 +19,10 @@ public async Task PublishMessageAsync(IOutgoingMessage message MessagePublishingFeatures features = default, CancellationToken cancellationToken = default) { - message.Content.ThrowIf().Null(); + if (message.Content.IsEmpty) + { + throw new ArgumentException("Message content is required."); + } if (environmentProfileIdentifier.TryGetValue(out long receiverId) is not true) { diff --git a/Sources/Falko.Talkie.Platforms.Telegram/Converters/IncomingMessageConverter.cs b/Sources/Falko.Talkie.Platforms.Telegram/Converters/IncomingMessageConverter.cs index 71ba8af..f3869ef 100644 --- a/Sources/Falko.Talkie.Platforms.Telegram/Converters/IncomingMessageConverter.cs +++ b/Sources/Falko.Talkie.Platforms.Telegram/Converters/IncomingMessageConverter.cs @@ -6,15 +6,14 @@ using Talkie.Models.Profiles; using Talkie.Platforms; using Talkie.Sequences; -using Talkie.Validations; - namespace Talkie.Converters; internal static class IncomingMessageConverter { public static TelegramIncomingMessage? Convert(TelegramPlatform platform, Message message) { - message.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(platform); + ArgumentNullException.ThrowIfNull(message); if (message.Text is not { } text) return null; diff --git a/Sources/Falko.Talkie.Platforms/Localizations/LanguageCodes.cs b/Sources/Falko.Talkie.Platforms/Localizations/LanguageCodes.cs index 0117a32..5788725 100644 --- a/Sources/Falko.Talkie.Platforms/Localizations/LanguageCodes.cs +++ b/Sources/Falko.Talkie.Platforms/Localizations/LanguageCodes.cs @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using System.Reflection; -using Talkie.Validations; namespace Talkie.Localizations; @@ -31,7 +30,7 @@ public static bool TryGetLanguageCode(this Language language, out LanguageCode l public static bool TryGetLanguageCode(string languageCodeName, out LanguageCode languageCode) { - languageCodeName.ThrowIf().NullOrEmpty(); + ArgumentException.ThrowIfNullOrWhiteSpace(languageCodeName); if (LanguageCodesByLanguageCodeName.TryGetValue(languageCodeName, out languageCode)) return true; diff --git a/Sources/Falko.Talkie.Platforms/Localizations/Languages.cs b/Sources/Falko.Talkie.Platforms/Localizations/Languages.cs index e23cc15..728278d 100644 --- a/Sources/Falko.Talkie.Platforms/Localizations/Languages.cs +++ b/Sources/Falko.Talkie.Platforms/Localizations/Languages.cs @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using System.Reflection; -using Talkie.Validations; namespace Talkie.Localizations; @@ -31,7 +30,7 @@ public static bool TryGetLanguage(this LanguageCode languageCode, out Language l public static bool TryGetLanguage(string languageName, out Language language) { - languageName.ThrowIf().NullOrEmpty(); + ArgumentException.ThrowIfNullOrWhiteSpace(languageName); if (LanguagesByLanguageName.TryGetValue(languageName, out language)) return true; diff --git a/Sources/Falko.Talkie.Platforms/Models/Identifier.cs b/Sources/Falko.Talkie.Platforms/Models/Identifier.cs index cfbefb8..348bf59 100644 --- a/Sources/Falko.Talkie.Platforms/Models/Identifier.cs +++ b/Sources/Falko.Talkie.Platforms/Models/Identifier.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Talkie.Validations; namespace Talkie.Models; @@ -116,7 +115,7 @@ public override int GetHashCode() /// The value is Null. public static Identifier FromValue(T value) where T : notnull { - value.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(value); return new Identifier(value); } diff --git a/Sources/Falko.Talkie.Platforms/Validations/ThrowableExtensions.cs b/Sources/Falko.Talkie.Platforms/Validations/ThrowableExtensions.cs deleted file mode 100644 index 08a1653..0000000 --- a/Sources/Falko.Talkie.Platforms/Validations/ThrowableExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Talkie.Models.Messages.Incoming; -using Talkie.Platforms; - -namespace Talkie.Validations; - -public static partial class ThrowableExtensions -{ - public static void NotPlatform(this Throwable throwable) where T : class, IPlatform - { - if (throwable.Value.Platform is not T) - { - throw new PlatformNotSupportedException($"Supports only {typeof(T).Name} platform."); - } - } -} diff --git a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Handling/ElementarySignalHandlingPipelineBuilder.cs b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Handling/ElementarySignalHandlingPipelineBuilder.cs index 138c9e2..286055f 100644 --- a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Handling/ElementarySignalHandlingPipelineBuilder.cs +++ b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Handling/ElementarySignalHandlingPipelineBuilder.cs @@ -1,7 +1,6 @@ using Talkie.Handlers; using Talkie.Pipelines.Intercepting; using Talkie.Sequences; -using Talkie.Validations; namespace Talkie.Pipelines.Handling; @@ -13,7 +12,7 @@ protected ElementarySignalHandlingPipelineBuilder() { } protected ElementarySignalHandlingPipelineBuilder(ISignalInterceptingPipeline? interceptingPipeline) { - interceptingPipeline.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(interceptingPipeline); Intercepting = interceptingPipeline; } diff --git a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/SingletonSignalInterceptorFactory.cs b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/SingletonSignalInterceptorFactory.cs index 1a7b3ab..fdc76c2 100644 --- a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/SingletonSignalInterceptorFactory.cs +++ b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/SingletonSignalInterceptorFactory.cs @@ -1,5 +1,4 @@ using Talkie.Interceptors; -using Talkie.Validations; namespace Talkie.Pipelines.Intercepting; @@ -13,7 +12,7 @@ public sealed class SingletonSignalInterceptorFactory : ISignalInterceptorFactor public SingletonSignalInterceptorFactory(Func interceptorFactory) { - interceptorFactory.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(interceptorFactory); _interceptorFactory = interceptorFactory; } @@ -30,7 +29,7 @@ public ISignalInterceptor Create() _interceptorFactory = null; - _interceptor.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(_interceptor); return _interceptor; } diff --git a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/SingletonSignalInterceptorFactory{T}.cs b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/SingletonSignalInterceptorFactory{T}.cs index 58967d4..94ee465 100644 --- a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/SingletonSignalInterceptorFactory{T}.cs +++ b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/SingletonSignalInterceptorFactory{T}.cs @@ -1,6 +1,5 @@ using Talkie.Interceptors; using Talkie.Signals; -using Talkie.Validations; namespace Talkie.Pipelines.Intercepting; @@ -14,7 +13,7 @@ public sealed class SingletonSignalInterceptorFactory : ISignalInterceptorFac public SingletonSignalInterceptorFactory(Func> interceptorFactory) { - interceptorFactory.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(interceptorFactory); _interceptorFactory = interceptorFactory; } @@ -31,7 +30,7 @@ public ISignalInterceptor Create() _interceptorFactory = null; - _interceptor.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(_interceptor); return _interceptor; } diff --git a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/TransientSignalInterceptorFactory.cs b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/TransientSignalInterceptorFactory.cs index c7409ec..6e4d23c 100644 --- a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/TransientSignalInterceptorFactory.cs +++ b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/TransientSignalInterceptorFactory.cs @@ -1,5 +1,4 @@ using Talkie.Interceptors; -using Talkie.Validations; namespace Talkie.Pipelines.Intercepting; @@ -9,7 +8,7 @@ public sealed class TransientSignalInterceptorFactory : ISignalInterceptorFactor public TransientSignalInterceptorFactory(Func interceptorFactory) { - interceptorFactory.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(interceptorFactory); _interceptorFactory = interceptorFactory; } @@ -18,7 +17,7 @@ public ISignalInterceptor Create() { var interceptor = _interceptorFactory(); - interceptor.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(interceptor); return interceptor; } diff --git a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/TransientSignalInterceptorFactory{T}.cs b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/TransientSignalInterceptorFactory{T}.cs index 793ef06..3b3c8ad 100644 --- a/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/TransientSignalInterceptorFactory{T}.cs +++ b/Sources/Falko.Talkie.Signals.Extensions/Pipelines/Intercepting/TransientSignalInterceptorFactory{T}.cs @@ -1,6 +1,5 @@ using Talkie.Interceptors; using Talkie.Signals; -using Talkie.Validations; namespace Talkie.Pipelines.Intercepting; @@ -10,7 +9,7 @@ public sealed class TransientSignalInterceptorFactory : ISignalInterceptorFac public TransientSignalInterceptorFactory(Func> interceptorFactory) { - interceptorFactory.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(interceptorFactory); _interceptorFactory = interceptorFactory; } @@ -19,7 +18,7 @@ public ISignalInterceptor Create() { var interceptor = _interceptorFactory(); - interceptor.ThrowIf().Null(); + ArgumentNullException.ThrowIfNull(interceptor); return interceptor; } diff --git a/Sources/Falko.Talkie.Signals/Flows/SignalFlow.cs b/Sources/Falko.Talkie.Signals/Flows/SignalFlow.cs index e9124cf..65b4d94 100644 --- a/Sources/Falko.Talkie.Signals/Flows/SignalFlow.cs +++ b/Sources/Falko.Talkie.Signals/Flows/SignalFlow.cs @@ -3,7 +3,6 @@ using Talkie.Pipelines.Handling; using Talkie.Sequences; using Talkie.Signals; -using Talkie.Validations; namespace Talkie.Flows; @@ -26,7 +25,7 @@ public SignalFlow() public Subscription Subscribe(ISignalHandlingPipeline handlingPipeline) { - _disposed.ThrowIf().Disposed(); + ObjectDisposedException.ThrowIf(_disposed, this); lock (_locker) {