From edfd16070e58ff8897de9a510d7a2887d9039744 Mon Sep 17 00:00:00 2001 From: Zebio21 <43841412+Zebio21@users.noreply.github.com> Date: Sun, 18 Apr 2021 14:36:17 +1100 Subject: [PATCH] Added ValidateNullOrNotEmpty --- CryptoExchange.Net/CryptoExchange.Net.csproj | 6 +++--- CryptoExchange.Net/CryptoExchange.Net.xml | 11 ++++++++--- CryptoExchange.Net/ExtensionMethods.cs | 11 +++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CryptoExchange.Net/CryptoExchange.Net.csproj b/CryptoExchange.Net/CryptoExchange.Net.csproj index aeb0426..08bb5a0 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.csproj +++ b/CryptoExchange.Net/CryptoExchange.Net.csproj @@ -6,16 +6,16 @@ CryptoExchange.Net JKorf A base package for implementing cryptocurrency exchange API's - 3.8.0 + 3.8.1 3.8.0 - 3.8.0 + 3.8.1 false git https://github.com/JKorf/CryptoExchange.Net.git https://github.com/JKorf/CryptoExchange.Net en true - 3.8.0 - Better handling of json errors while deserializing stream, Added string datetime converter + 3.8.1 - Added ValidateNullOrNotEmpty method extension enable 8.0 MIT diff --git a/CryptoExchange.Net/CryptoExchange.Net.xml b/CryptoExchange.Net/CryptoExchange.Net.xml index 2717450..81581de 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.xml +++ b/CryptoExchange.Net/CryptoExchange.Net.xml @@ -930,6 +930,13 @@ The value of the string Name of the parameter + + + Validates a string is null or not empty + + + + Validates an object is not null @@ -3512,9 +3519,7 @@ - - -System.Diagnostics.CodeAnalysis.AllowNullAttribute"> + Specifies that is allowed as an input even if the corresponding type disallows it. diff --git a/CryptoExchange.Net/ExtensionMethods.cs b/CryptoExchange.Net/ExtensionMethods.cs index 3f1df21..92dfe73 100644 --- a/CryptoExchange.Net/ExtensionMethods.cs +++ b/CryptoExchange.Net/ExtensionMethods.cs @@ -253,6 +253,17 @@ namespace CryptoExchange.Net throw new ArgumentException($"No value provided for parameter {argumentName}", argumentName); } + /// + /// Validates a string is null or not empty + /// + /// + /// + public static void ValidateNullOrNotEmpty(this string value, string argumentName) + { + if (value != null && string.IsNullOrEmpty(value)) + throw new ArgumentException($"No value provided for parameter {argumentName}", argumentName); + } + /// /// Validates an object is not null ///