Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Updates azure task generator
  • Loading branch information
mzorec committed Oct 9, 2018
1 parent 0524f21 commit daf92c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions FlubuCore.Azure/AzureTaskGenerator.cs
Expand Up @@ -19,7 +19,9 @@ protected override string WriteParameter(Parameter parameter)
return string.Empty;
}

return $"{parameter.ParameterType} {parameter.ParameterName} = null";
string parameterName = ParameterName(parameter.ParameterName);

return $"{parameter.ParameterType} {parameterName} = null";
}

protected override string WriteArgument(Argument argument)
Expand All @@ -34,10 +36,12 @@ protected override string WriteArgument(Argument argument)
return $@"WithArguments(""{argument.ArgumentKey}"");";
}

var parameterName = ParameterName(argument.Parameter.ParameterName);

return $@"WithArguments(""{argument.ArgumentKey}"");
if (!string.IsNullOrEmpty({argument.Parameter.ParameterName}))
if (!string.IsNullOrEmpty({parameterName}))
{{
WithArguments({argument.Parameter.ParameterName});
WithArguments({parameterName});
}}
";
}
Expand Down
13 changes: 13 additions & 0 deletions FlubuCore.Azure/StringExtensions.cs
Expand Up @@ -16,5 +16,18 @@ public static string FirstCharToUpper(this string value)
default: return value.First().ToString().ToUpper() + value.Substring(1);
}
}

public static IEnumerable<TSource> DistinctBy<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
{
if (seenKeys.Add(keySelector(element)))
{
yield return element;
}
}
}
}
}

0 comments on commit daf92c0

Please sign in to comment.