Refactor default parameter values to use null instead of default.
Replaced `default` with `null` for optional parameters across several classes to improve clarity and consistency. This change aligns with typical .NET conventions and ensures more predictable behavior when handling optional arguments.
This commit is contained in:
parent
0e6fdc7e0d
commit
fdc57945e8
|
|
@ -12,11 +12,11 @@ public class ActivityWorkItem
|
|||
/// </summary>
|
||||
public ActivityWorkItem(
|
||||
IActivity activity,
|
||||
ActivityExecutionContext? owner = default,
|
||||
object? tag = default,
|
||||
IEnumerable<Variable>? variables = default,
|
||||
ActivityExecutionContext? existingActivityExecutionContext = default,
|
||||
IDictionary<string, object>? input = default)
|
||||
ActivityExecutionContext? owner = null,
|
||||
object? tag = null,
|
||||
IEnumerable<Variable>? variables = null,
|
||||
ActivityExecutionContext? existingActivityExecutionContext = null,
|
||||
IDictionary<string, object>? input = null)
|
||||
{
|
||||
Activity = activity;
|
||||
Owner = owner;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Elsa.Workflows.Runtime.Activities;
|
|||
public class PublishEvent : Activity
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public PublishEvent([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
|
||||
public PublishEvent([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -22,25 +22,25 @@ public class PublishEvent : Activity
|
|||
/// The name of the event to publish.
|
||||
/// </summary>
|
||||
[Input(Description = "The name of the event to publish.")]
|
||||
public Input<string> EventName { get; set; } = default!;
|
||||
public Input<string> EventName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The correlation ID to scope the event to.
|
||||
/// </summary>
|
||||
[Input(Description = "The correlation ID to scope the event to.")]
|
||||
public Input<string?> CorrelationId { get; set; } = default!;
|
||||
public Input<string?> CorrelationId { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the event is local to the workflow.
|
||||
/// </summary>
|
||||
[Input(DisplayName = "Local event", Description = "Whether the event is local to the workflow. When checked, the event will be delivered to this workflow instance only.")]
|
||||
public Input<bool> IsLocalEvent { get; set; } = default!;
|
||||
public Input<bool> IsLocalEvent { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The input to send as the event body.
|
||||
/// </summary>
|
||||
[Input(Description = "The payload to send as the event body.")]
|
||||
public Input<object> Payload { get; set; } = default!;
|
||||
public Input<object> Payload { get; set; } = null!;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
|
||||
|
|
@ -48,7 +48,7 @@ public class PublishEvent : Activity
|
|||
var eventName = EventName.Get(context);
|
||||
var correlationId = CorrelationId.GetOrDefault(context);
|
||||
var isLocalEvent = IsLocalEvent.GetOrDefault(context);
|
||||
var workflowInstanceId = isLocalEvent ? context.WorkflowExecutionContext.Id : default;
|
||||
var workflowInstanceId = isLocalEvent ? context.WorkflowExecutionContext.Id : null;
|
||||
var payload = Payload.GetOrDefault(context);
|
||||
var publisher = context.GetRequiredService<IEventPublisher>();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ public class EventPublisher(IStimulusSender stimulusSender) : IEventPublisher
|
|||
/// <inheritdoc />
|
||||
public async Task PublishAsync(
|
||||
string eventName,
|
||||
string? correlationId = default,
|
||||
string? workflowInstanceId = default,
|
||||
string? activityInstanceId = default,
|
||||
object? payload = default,
|
||||
string? correlationId = null,
|
||||
string? workflowInstanceId = null,
|
||||
string? activityInstanceId = null,
|
||||
object? payload = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var stimulus = new EventStimulus(eventName);
|
||||
|
|
|
|||
Loading…
Reference in a new issue