Refactor ASF commands for future actions

Closes #891
This commit is contained in:
JustArchi
2018-09-15 22:34:32 +02:00
parent 3027f16f4e
commit 7ab19aa806
9 changed files with 3148 additions and 3169 deletions

View File

@@ -25,6 +25,7 @@ using System.Globalization;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Humanizer;
@@ -105,6 +106,15 @@ namespace ArchiSteamFarm {
Task.Factory.StartNew(function, CancellationToken.None, options, TaskScheduler.Default);
}
internal static bool IsValidCdKey(string key) {
if (string.IsNullOrEmpty(key)) {
ASF.ArchiLogger.LogNullError(nameof(key));
return false;
}
return Regex.IsMatch(key, @"^[0-9A-Z]{4,7}-[0-9A-Z]{4,7}-[0-9A-Z]{4,7}(?:(?:-[0-9A-Z]{4,7})?(?:-[0-9A-Z]{4,7}))?$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
}
internal static bool IsValidHexadecimalString(string text) {
if (string.IsNullOrEmpty(text)) {
ASF.ArchiLogger.LogNullError(nameof(text));