diff --git a/FlubuCore.Azure/AzureTaskGenerator.cs b/FlubuCore.Azure/AzureTaskGenerator.cs new file mode 100644 index 0000000..510dfda --- /dev/null +++ b/FlubuCore.Azure/AzureTaskGenerator.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; +using FlubuCore.TaskGenerator.Models; +using Scripty.Core; + +namespace FlubuCore.Azure +{ + public class AzureTaskGenerator : TaskGenerator.TaskGenerator + { + public AzureTaskGenerator(ScriptContext context) : base(context) + { + } + + protected override string WriteParameter(Parameter parameter) + { + if (parameter == null) + { + return string.Empty; + } + + return $"{parameter.ParameterType} {parameter.ParameterName} = null"; + } + + protected override string WriteArgument(Argument argument) + { + if (argument == null) + { + return string.Empty; + } + + if (argument.Parameter == null) + { + return $@"WithArguments(""{argument.ArgumentKey}"");"; + } + + return $@"WithArguments(""{argument.ArgumentKey}""); + if (!string.IsNullOrEmpty({argument.Parameter.ParameterName})) + {{ + WithArguments({argument.Parameter.ParameterName}); + }} +"; + } + } +} diff --git a/FlubuCore.Azure/StringExtensions.cs b/FlubuCore.Azure/StringExtensions.cs new file mode 100644 index 0000000..8535303 --- /dev/null +++ b/FlubuCore.Azure/StringExtensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace FlubuCore.Azure +{ + public static class StringExtensions + { + public static string FirstCharToUpper(this string value) + { + switch (value) + { + case null: throw new ArgumentNullException(nameof(value)); + case "": throw new ArgumentException($"{nameof(value)} cannot be empty", nameof(value)); + default: return value.First().ToString().ToUpper() + value.Substring(1); + } + } + } +}