diff --git a/Utilities/Actions/Arrays.cs b/Utilities/Actions/Arrays.cs new file mode 100644 index 0000000..d8a159e --- /dev/null +++ b/Utilities/Actions/Arrays.cs @@ -0,0 +1,23 @@ +using Apps.Utilities.Models.Arrays.Request; +using Apps.Utilities.Models.Arrays.Response; +using Blackbird.Applications.Sdk.Common; +using Blackbird.Applications.Sdk.Common.Actions; +using Blackbird.Applications.Sdk.Common.Invocation; + +namespace Apps.Utilities.Actions; + +public class Arrays : BaseInvocable +{ + public Arrays(InvocationContext invocationContext) : base(invocationContext) + { + } + + [Action("Array contains", Description = "Check if array contains a ceratin entry")] + public ArrayContainsResponse GenerateDate([ActionParameter] ArrayContainsRequest input) + { + return new() + { + Contains = input.Array.Contains(input.Entry) + }; + } +} \ No newline at end of file diff --git a/Utilities/Actions/Dates.cs b/Utilities/Actions/Dates.cs index 6aef8b4..6fb5378 100644 --- a/Utilities/Actions/Dates.cs +++ b/Utilities/Actions/Dates.cs @@ -1,31 +1,25 @@ using Blackbird.Applications.Sdk.Common; using Blackbird.Applications.Sdk.Common.Actions; using Blackbird.Applications.Sdk.Common.Invocation; -using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Apps.Utilities.Models.Dates; -namespace Apps.Utilities.Actions +namespace Apps.Utilities.Actions; + +[ActionList] +public class Dates : BaseInvocable { - [ActionList] - public class Dates : BaseInvocable - { - public Dates(InvocationContext context) : base(context) { } + public Dates(InvocationContext context) : base(context) { } - [Action("Generate date", Description = "Generate a date relative to the moment this action is called.")] - public DateResponse GenerateDate([ActionParameter] GenerateDateRequest input) - { - return new DateResponse { Date = DateTime.Now.AddDays(input.AddDays ?? 0).AddHours(input.AddHours ?? 0).AddMinutes(input.AddMinutes ?? 0) }; - } + [Action("Generate date", Description = "Generate a date relative to the moment this action is called.")] + public DateResponse GenerateDate([ActionParameter] GenerateDateRequest input) + { + return new DateResponse { Date = DateTime.Now.AddDays(input.AddDays ?? 0).AddHours(input.AddHours ?? 0).AddMinutes(input.AddMinutes ?? 0) }; + } - [Action("Format date", Description = "Format a date to text according to pre-defined formatting rules and culture")] - public FormattedDateResponse FormatDate([ActionParameter] FormatDateRequest input ) - { - return new FormattedDateResponse { FormattedDate = input.Date.ToString(input.Format, input.Culture != null ? new CultureInfo(input.Culture) : CultureInfo.InvariantCulture) }; - } + [Action("Format date", Description = "Format a date to text according to pre-defined formatting rules and culture")] + public FormattedDateResponse FormatDate([ActionParameter] FormatDateRequest input ) + { + return new FormattedDateResponse { FormattedDate = input.Date.ToString(input.Format, input.Culture != null ? new CultureInfo(input.Culture) : CultureInfo.InvariantCulture) }; } -} +} \ No newline at end of file diff --git a/Utilities/Actions/Files.cs b/Utilities/Actions/Files.cs index ae7a035..aae6cd8 100644 --- a/Utilities/Actions/Files.cs +++ b/Utilities/Actions/Files.cs @@ -1,47 +1,40 @@ -using Apps.Utilities.Models.Dates; -using Apps.Utilities.Models.Files; +using Apps.Utilities.Models.Files; using Apps.Utilities.Models.Shared; using Blackbird.Applications.Sdk.Common; using Blackbird.Applications.Sdk.Common.Actions; using Blackbird.Applications.Sdk.Common.Invocation; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.Actions +namespace Apps.Utilities.Actions; + +[ActionList] +public class Files : BaseInvocable { - [ActionList] - public class Files : BaseInvocable - { - public Files(InvocationContext context) : base(context) { } + public Files(InvocationContext context) : base(context) { } - [Action("Get file name", Description = "Returns the name of a file (without extension).")] - public NameResponse GetFileName([ActionParameter] FileDto file) - { - return new NameResponse { Name = Path.GetFileNameWithoutExtension(file.File.Name) }; - } + [Action("Get file name", Description = "Returns the name of a file (without extension).")] + public NameResponse GetFileName([ActionParameter] FileDto file) + { + return new NameResponse { Name = Path.GetFileNameWithoutExtension(file.File.Name) }; + } - [Action("Change file name", Description = "Rename a file (without extension).")] - public FileDto ChangeFileName([ActionParameter] FileDto file, [ActionParameter] RenameRequest input) - { - var extension = Path.GetExtension(file.File.Name); - file.File.Name = input.Name + extension; - return new FileDto { File = file.File }; - } + [Action("Change file name", Description = "Rename a file (without extension).")] + public FileDto ChangeFileName([ActionParameter] FileDto file, [ActionParameter] RenameRequest input) + { + var extension = Path.GetExtension(file.File.Name); + file.File.Name = input.Name + extension; + return new FileDto { File = file.File }; + } - [Action("Sanitize file name", Description = "Remove any defined characters from a file name (without extension).")] - public FileDto SanitizeFileName([ActionParameter] FileDto file, [ActionParameter] SanitizeRequest input) + [Action("Sanitize file name", Description = "Remove any defined characters from a file name (without extension).")] + public FileDto SanitizeFileName([ActionParameter] FileDto file, [ActionParameter] SanitizeRequest input) + { + var extension = Path.GetExtension(file.File.Name); + var newName = file.File.Name; + foreach (string filteredCharacter in input.FilterCharacters) { - var extension = Path.GetExtension(file.File.Name); - var newName = file.File.Name; - foreach (string filteredCharacter in input.FilterCharacters) - { - newName = newName.Replace(filteredCharacter, string.Empty); - } - file.File.Name = newName + extension; - return new FileDto { File = file.File }; + newName = newName.Replace(filteredCharacter, string.Empty); } + file.File.Name = newName + extension; + return new FileDto { File = file.File }; } -} +} \ No newline at end of file diff --git a/Utilities/Actions/Texts.cs b/Utilities/Actions/Texts.cs index 4b9325f..d5570de 100644 --- a/Utilities/Actions/Texts.cs +++ b/Utilities/Actions/Texts.cs @@ -1,31 +1,24 @@ -using Apps.Utilities.Models.Files; -using Apps.Utilities.Models.Shared; +using Apps.Utilities.Models.Shared; using Apps.Utilities.Models.Texts; using Blackbird.Applications.Sdk.Common; using Blackbird.Applications.Sdk.Common.Actions; using Blackbird.Applications.Sdk.Common.Invocation; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.Actions +namespace Apps.Utilities.Actions; + +[ActionList] +public class Texts : BaseInvocable { - [ActionList] - public class Texts : BaseInvocable - { - public Texts(InvocationContext context) : base(context) { } + public Texts(InvocationContext context) : base(context) { } - [Action("Sanitize text", Description = "Remove any defined characters from a text.")] - public TextDto SanitizeText([ActionParameter] TextDto text, [ActionParameter] SanitizeRequest input) + [Action("Sanitize text", Description = "Remove any defined characters from a text.")] + public TextDto SanitizeText([ActionParameter] TextDto text, [ActionParameter] SanitizeRequest input) + { + var newText = text.Text; + foreach (string filteredCharacter in input.FilterCharacters) { - var newText = text.Text; - foreach (string filteredCharacter in input.FilterCharacters) - { - newText = newText.Replace(filteredCharacter, string.Empty); - } - return new TextDto { Text = newText }; + newText = newText.Replace(filteredCharacter, string.Empty); } + return new TextDto { Text = newText }; } -} +} \ No newline at end of file diff --git a/Utilities/Application.cs b/Utilities/Application.cs index 960c877..e96a0bf 100644 --- a/Utilities/Application.cs +++ b/Utilities/Application.cs @@ -1,18 +1,17 @@ using Blackbird.Applications.Sdk.Common; -namespace Apps.Utilities +namespace Apps.Utilities; + +public class Application : IApplication { - public class Application : IApplication + public string Name { - public string Name - { - get => "Utilities"; - set { } - } + get => "Utilities"; + set { } + } - public T GetInstance() - { - throw new NotImplementedException(); - } + public T GetInstance() + { + throw new NotImplementedException(); } } \ No newline at end of file diff --git a/Utilities/Apps.Utilities.csproj b/Utilities/Apps.Utilities.csproj index 1fa4bd6..2e6641e 100644 --- a/Utilities/Apps.Utilities.csproj +++ b/Utilities/Apps.Utilities.csproj @@ -5,7 +5,7 @@ enable Utilities Various utility actions to parse or convert data - 1.0.6 + 1.1.0 Apps.Utilities diff --git a/Utilities/Connections/ConnectionDefinition.cs b/Utilities/Connections/ConnectionDefinition.cs index f6e5ce8..9874eb1 100644 --- a/Utilities/Connections/ConnectionDefinition.cs +++ b/Utilities/Connections/ConnectionDefinition.cs @@ -1,31 +1,25 @@ using Blackbird.Applications.Sdk.Common.Authentication; using Blackbird.Applications.Sdk.Common.Connections; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.Connections +namespace Apps.Utilities.Connections; + +public class ConnectionDefinition : IConnectionDefinition { - public class ConnectionDefinition : IConnectionDefinition - { - public IEnumerable ConnectionPropertyGroups => new List() + public IEnumerable ConnectionPropertyGroups => new List() + { + new() { - new() - { - Name = "Utilities connection", - AuthenticationType = ConnectionAuthenticationType.Undefined, - ConnectionUsage = ConnectionUsage.Actions, - ConnectionProperties = new List() - } - }; + Name = "Utilities connection", + AuthenticationType = ConnectionAuthenticationType.Undefined, + ConnectionUsage = ConnectionUsage.Actions, + ConnectionProperties = new List() + } + }; - public IEnumerable CreateAuthorizationCredentialsProviders( + public IEnumerable CreateAuthorizationCredentialsProviders( Dictionary values) - { - return new AuthenticationCredentialsProvider[] { }; - } + { + return new AuthenticationCredentialsProvider[] { }; } -} +} \ No newline at end of file diff --git a/Utilities/Connections/ConnectionValidator.cs b/Utilities/Connections/ConnectionValidator.cs index 4bc4f8b..b9a53f1 100644 --- a/Utilities/Connections/ConnectionValidator.cs +++ b/Utilities/Connections/ConnectionValidator.cs @@ -1,22 +1,16 @@ using Blackbird.Applications.Sdk.Common.Authentication; using Blackbird.Applications.Sdk.Common.Connections; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.Connections +namespace Apps.Utilities.Connections; + +public class ConnectionValidator : IConnectionValidator { - public class ConnectionValidator : IConnectionValidator + public ValueTask ValidateConnection( + IEnumerable authProviders, CancellationToken cancellationToken) { - public ValueTask ValidateConnection( - IEnumerable authProviders, CancellationToken cancellationToken) + return new(Task.FromResult(new ConnectionValidationResponse() { - return new(Task.FromResult(new ConnectionValidationResponse() - { - IsValid = true - })); - } + IsValid = true + })); } -} +} \ No newline at end of file diff --git a/Utilities/DataSourceHandlers/CultureSourceHandler.cs b/Utilities/DataSourceHandlers/CultureSourceHandler.cs index f04949b..64cc514 100644 --- a/Utilities/DataSourceHandlers/CultureSourceHandler.cs +++ b/Utilities/DataSourceHandlers/CultureSourceHandler.cs @@ -1,23 +1,17 @@ using Blackbird.Applications.Sdk.Common.Dynamic; -using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.DataSourceHandlers +namespace Apps.Utilities.DataSourceHandlers; + +public class CultureSourceHandler : IDataSourceHandler { - public class CultureSourceHandler : IDataSourceHandler + public Dictionary GetData(DataSourceContext context) { - public Dictionary GetData(DataSourceContext context) - { - var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); - return cultures - // Applying user search query to the response - .Where(x => context.SearchString == null || - x.EnglishName.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase)) - .ToDictionary(x => x.Name, x => x.EnglishName); - } + var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); + return cultures + // Applying user search query to the response + .Where(x => context.SearchString == null || + x.EnglishName.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase)) + .ToDictionary(x => x.Name, x => x.EnglishName); } -} +} \ No newline at end of file diff --git a/Utilities/DataSourceHandlers/DateFormatSourceHandler.cs b/Utilities/DataSourceHandlers/DateFormatSourceHandler.cs index de50869..84cafb1 100644 --- a/Utilities/DataSourceHandlers/DateFormatSourceHandler.cs +++ b/Utilities/DataSourceHandlers/DateFormatSourceHandler.cs @@ -1,37 +1,31 @@ using Blackbird.Applications.Sdk.Common.Dynamic; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.DataSourceHandlers +namespace Apps.Utilities.DataSourceHandlers; + +public class DateFormatSourceHandler : IDataSourceHandler { - public class DateFormatSourceHandler : IDataSourceHandler + private Dictionary EnumValues => new() { - private Dictionary EnumValues => new() - { - {"d", "Short date"}, - {"D", "Long date"}, - {"f", "Full date/time (short time)"}, - {"F", "Full date/time (long time)" }, - {"g", "General date/time (short time)"}, - {"G", "General date/time (long time)" }, - {"M", "Month/day" }, - {"R", "RFC1123" }, - {"t", "Short time" }, - {"T", "Long time" }, - {"U", "Universal full date/time" }, - {"Y", "Year month" } - }; + {"d", "Short date"}, + {"D", "Long date"}, + {"f", "Full date/time (short time)"}, + {"F", "Full date/time (long time)" }, + {"g", "General date/time (short time)"}, + {"G", "General date/time (long time)" }, + {"M", "Month/day" }, + {"R", "RFC1123" }, + {"t", "Short time" }, + {"T", "Long time" }, + {"U", "Universal full date/time" }, + {"Y", "Year month" } + }; - public Dictionary GetData(DataSourceContext context) - { - return EnumValues - // Applying user search query to the response - .Where(x => context.SearchString == null || - x.Value.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase)) - .ToDictionary(x => x.Key, x => x.Value); - } + public Dictionary GetData(DataSourceContext context) + { + return EnumValues + // Applying user search query to the response + .Where(x => context.SearchString == null || + x.Value.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase)) + .ToDictionary(x => x.Key, x => x.Value); } -} +} \ No newline at end of file diff --git a/Utilities/Models/Arrays/Request/ArrayContainsRequest.cs b/Utilities/Models/Arrays/Request/ArrayContainsRequest.cs new file mode 100644 index 0000000..4e8d48d --- /dev/null +++ b/Utilities/Models/Arrays/Request/ArrayContainsRequest.cs @@ -0,0 +1,8 @@ +namespace Apps.Utilities.Models.Arrays.Request; + +public class ArrayContainsRequest +{ + public IEnumerable Array { get; set; } + + public string Entry { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Arrays/Response/ArrayContainsResponse.cs b/Utilities/Models/Arrays/Response/ArrayContainsResponse.cs new file mode 100644 index 0000000..7a45b16 --- /dev/null +++ b/Utilities/Models/Arrays/Response/ArrayContainsResponse.cs @@ -0,0 +1,6 @@ +namespace Apps.Utilities.Models.Arrays.Response; + +public class ArrayContainsResponse +{ + public bool Contains { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Dates/DateResponse.cs b/Utilities/Models/Dates/DateResponse.cs index bf673c4..bf37145 100644 --- a/Utilities/Models/Dates/DateResponse.cs +++ b/Utilities/Models/Dates/DateResponse.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Apps.Utilities.Models.Dates; -namespace Apps.Utilities.Models.Dates +public class DateResponse { - public class DateResponse - { - public DateTime Date { get; set; } - } -} + public DateTime Date { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Dates/FormatDateRequest.cs b/Utilities/Models/Dates/FormatDateRequest.cs index 979ce37..698c257 100644 --- a/Utilities/Models/Dates/FormatDateRequest.cs +++ b/Utilities/Models/Dates/FormatDateRequest.cs @@ -1,25 +1,19 @@ using Blackbird.Applications.Sdk.Common; using Blackbird.Applications.Sdk.Common.Dynamic; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Apps.Utilities.DataSourceHandlers; -namespace Apps.Utilities.Models.Dates +namespace Apps.Utilities.Models.Dates; + +public class FormatDateRequest { - public class FormatDateRequest - { - [Display("Date")] - public DateTime Date { get; set; } + [Display("Date")] + public DateTime Date { get; set; } - [Display("Format")] - [DataSource(typeof(DateFormatSourceHandler))] - public string Format { get; set; } + [Display("Format")] + [DataSource(typeof(DateFormatSourceHandler))] + public string Format { get; set; } - [Display("Culture")] - [DataSource(typeof(CultureSourceHandler))] - public string? Culture { get; set; } - } -} + [Display("Culture")] + [DataSource(typeof(CultureSourceHandler))] + public string? Culture { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Dates/FormattedDateResponse.cs b/Utilities/Models/Dates/FormattedDateResponse.cs index 5f78f21..6ba0385 100644 --- a/Utilities/Models/Dates/FormattedDateResponse.cs +++ b/Utilities/Models/Dates/FormattedDateResponse.cs @@ -1,15 +1,9 @@ using Blackbird.Applications.Sdk.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.Models.Dates +namespace Apps.Utilities.Models.Dates; + +public class FormattedDateResponse { - public class FormattedDateResponse - { - [Display("Formatted date")] - public string FormattedDate { get; set; } - } -} + [Display("Formatted date")] + public string FormattedDate { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Dates/GenerateDateRequest.cs b/Utilities/Models/Dates/GenerateDateRequest.cs index bb3e6b2..83b377a 100644 --- a/Utilities/Models/Dates/GenerateDateRequest.cs +++ b/Utilities/Models/Dates/GenerateDateRequest.cs @@ -1,21 +1,15 @@ using Blackbird.Applications.Sdk.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.Models.Dates +namespace Apps.Utilities.Models.Dates; + +public class GenerateDateRequest { - public class GenerateDateRequest - { - [Display("Add days")] - public double? AddDays { get; set; } + [Display("Add days")] + public double? AddDays { get; set; } - [Display("Add hours")] - public double? AddHours { get; set; } + [Display("Add hours")] + public double? AddHours { get; set; } - [Display("Add minutes")] - public double? AddMinutes { get; set; } - } -} + [Display("Add minutes")] + public double? AddMinutes { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Files/FileDto.cs b/Utilities/Models/Files/FileDto.cs index 6b87c24..5fa428a 100644 --- a/Utilities/Models/Files/FileDto.cs +++ b/Utilities/Models/Files/FileDto.cs @@ -1,16 +1,9 @@ -using Blackbird.Applications.Sdk.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using File = Blackbird.Applications.Sdk.Common.Files.File; +using File = Blackbird.Applications.Sdk.Common.Files.File; -namespace Apps.Utilities.Models.Files +namespace Apps.Utilities.Models.Files; + +public class FileDto { - public class FileDto - { - public File File { get; set; } + public File File { get; set; } - } -} +} \ No newline at end of file diff --git a/Utilities/Models/Files/NameResponse.cs b/Utilities/Models/Files/NameResponse.cs index c479a3e..f9ede72 100644 --- a/Utilities/Models/Files/NameResponse.cs +++ b/Utilities/Models/Files/NameResponse.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Apps.Utilities.Models.Files; -namespace Apps.Utilities.Models.Files +public class NameResponse { - public class NameResponse - { - public string Name { get; set; } - } -} + public string Name { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Files/RenameRequest.cs b/Utilities/Models/Files/RenameRequest.cs index 997186b..dcc0ad7 100644 --- a/Utilities/Models/Files/RenameRequest.cs +++ b/Utilities/Models/Files/RenameRequest.cs @@ -1,15 +1,9 @@ using Blackbird.Applications.Sdk.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.Models.Files +namespace Apps.Utilities.Models.Files; + +public class RenameRequest { - public class RenameRequest - { - [Display("New name")] - public string Name { get; set; } - } -} + [Display("New name")] + public string Name { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Shared/SanitizeRequest.cs b/Utilities/Models/Shared/SanitizeRequest.cs index fea748e..bf2a543 100644 --- a/Utilities/Models/Shared/SanitizeRequest.cs +++ b/Utilities/Models/Shared/SanitizeRequest.cs @@ -1,15 +1,9 @@ using Blackbird.Applications.Sdk.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Apps.Utilities.Models.Shared +namespace Apps.Utilities.Models.Shared; + +public class SanitizeRequest { - public class SanitizeRequest - { - [Display("Characters to remove")] - public IEnumerable FilterCharacters { get; set; } - } -} + [Display("Characters to remove")] + public IEnumerable FilterCharacters { get; set; } +} \ No newline at end of file diff --git a/Utilities/Models/Texts/TextDto.cs b/Utilities/Models/Texts/TextDto.cs index 83a4ca1..6ef8498 100644 --- a/Utilities/Models/Texts/TextDto.cs +++ b/Utilities/Models/Texts/TextDto.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Apps.Utilities.Models.Texts; -namespace Apps.Utilities.Models.Texts +public class TextDto { - public class TextDto - { - public string Text { get; set; } - } -} + public string Text { get; set; } +} \ No newline at end of file