Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix null prefix #151

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/ConductorSharp.Definitions/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
pipelines.AddRequestResponseLogging();
pipelines.AddValidation();
})
.AddCSharpLambdaTasks(typeof(ITaskRequestHandler<,>).Assembly.GetName().Name);
.AddCSharpLambdaTasks();

builder.RegisterModule<ConductorModule>();
}
Expand Down
11 changes: 7 additions & 4 deletions src/ConductorSharp.Patterns/Builders/CSharpLambdaTaskBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ Func<TInput, TOutput> lambda
where TWorkflow : ITypedWorkflow
where TInput : IRequest<TOutput>
{
var lambdaTaskNamePrefix = (string)
builder.ConfigurationProperties.FirstOrDefault(prop => prop.Key == CSharpLambdaTask.LambdaTaskNameConfigurationProperty).Value;
var prefixConfigProperty = builder.ConfigurationProperties.FirstOrDefault(
prop => prop.Key == CSharpLambdaTask.LambdaTaskNameConfigurationProperty
);

if (lambdaTaskNamePrefix == null)
if (prefixConfigProperty == null)
throw new LambdaTasksNotEnabledException();

var lambdaTaskNamePrefix = TaskNameBuilder.MakeTaskNamePrefix(prefixConfigProperty.Value as string);

var taskBuilder = new CSharpLambdaTaskBuilder<TInput, TOutput>(
task.Body,
input.Body,
Expand Down Expand Up @@ -73,7 +76,7 @@ public override WorkflowDefinition.Task[] Build()
{
new WorkflowDefinition.Task
{
Name = $"{_lambdaTaskNamePrefix}.{CSharpLambdaTask.TaskName}",
Name = $"{_lambdaTaskNamePrefix}{CSharpLambdaTask.TaskName}",
TaskReferenceName = _taskRefferenceName,
InputParameters = new JObject
{
Expand Down
4 changes: 3 additions & 1 deletion src/ConductorSharp.Patterns/Builders/TaskNameBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public override string Build(Type taskType) =>
private string GetLambdaTaskPrefix()
{
var prefix = (string)_configurationProperties.First(prop => prop.Key == CSharpLambdaTask.LambdaTaskNameConfigurationProperty).Value;
return prefix == null ? string.Empty : $"{prefix}.";
return MakeTaskNamePrefix(prefix);
}

public static string MakeTaskNamePrefix(string prefix) => prefix == null ? string.Empty : $"{prefix}.";
}
}
Loading