Skip to content

Commit

Permalink
Azure task generator
Browse files Browse the repository at this point in the history
  • Loading branch information
mzorec committed Oct 6, 2018
1 parent 8436dbe commit 4ca6b40
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
45 changes: 45 additions & 0 deletions 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});
}}
";
}
}
}
20 changes: 20 additions & 0 deletions 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);
}
}
}
}

0 comments on commit 4ca6b40

Please sign in to comment.