diff --git a/src/Dapr.Workflow/DaprWorkflowActivityContext.cs b/src/Dapr.Workflow/DaprWorkflowActivityContext.cs
new file mode 100644
index 000000000..cf902dea4
--- /dev/null
+++ b/src/Dapr.Workflow/DaprWorkflowActivityContext.cs
@@ -0,0 +1,37 @@
+// ------------------------------------------------------------------------
+// Copyright 2022 The Dapr Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ------------------------------------------------------------------------
+
+namespace Dapr.Workflow
+{
+ using System;
+ using Microsoft.DurableTask;
+
+ ///
+ /// Defines properties and methods for task activity context objects.
+ ///
+ public class DaprWorkflowActivityContext : WorkflowActivityContext
+ {
+ readonly TaskActivityContext innerContext;
+
+ internal DaprWorkflowActivityContext(TaskActivityContext innerContext)
+ {
+ this.innerContext = innerContext ?? throw new ArgumentNullException(nameof(innerContext));
+ }
+
+ ///
+ public override TaskName Name => this.innerContext.Name;
+
+ ///
+ public override string InstanceId => this.innerContext.InstanceId;
+ }
+}
diff --git a/src/Dapr.Workflow/WorkflowActivityContext.cs b/src/Dapr.Workflow/WorkflowActivityContext.cs
index eec32f008..a77c3ef91 100644
--- a/src/Dapr.Workflow/WorkflowActivityContext.cs
+++ b/src/Dapr.Workflow/WorkflowActivityContext.cs
@@ -13,29 +13,21 @@
namespace Dapr.Workflow
{
- using System;
using Microsoft.DurableTask;
///
/// Defines properties and methods for task activity context objects.
///
- public class WorkflowActivityContext
+ public abstract class WorkflowActivityContext
{
- readonly TaskActivityContext innerContext;
-
- internal WorkflowActivityContext(TaskActivityContext innerContext)
- {
- this.innerContext = innerContext ?? throw new ArgumentNullException(nameof(innerContext));
- }
-
///
/// Gets the name of the activity.
///
- public TaskName Name => this.innerContext.Name;
+ public abstract TaskName Name { get; }
///
/// Gets the unique ID of the current workflow instance.
///
- public string InstanceId => this.innerContext.InstanceId;
+ public abstract string InstanceId { get; }
}
}
diff --git a/src/Dapr.Workflow/WorkflowRuntimeOptions.cs b/src/Dapr.Workflow/WorkflowRuntimeOptions.cs
index 9f0081783..9afdfb5e7 100644
--- a/src/Dapr.Workflow/WorkflowRuntimeOptions.cs
+++ b/src/Dapr.Workflow/WorkflowRuntimeOptions.cs
@@ -97,7 +97,7 @@ public void RegisterActivity(string name, Func(name, (innerContext, input) =>
{
- WorkflowActivityContext activityContext = new(innerContext);
+ WorkflowActivityContext activityContext = new DaprWorkflowActivityContext(innerContext);
return implementation(activityContext, input);
});
WorkflowLoggingService.LogActivityName(name);
@@ -183,7 +183,7 @@ public ActivityWrapper(IWorkflowActivity activity)
public Task