-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ParallelTracking namespace (#311)
Co-authored-by: vuplea <vuplea>
- Loading branch information
Showing
5 changed files
with
27 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 23 additions & 27 deletions
50
src/UiPath.Workflow.Runtime/ParallelTrackingExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,31 @@ | ||
using System; | ||
using System.Activities; | ||
namespace System.Activities.ParallelTracking; | ||
|
||
namespace UiPath.Workflow.Runtime.ParallelTracking | ||
/// <summary> | ||
/// This feature introduces a context.GetCurrentParallelId() queryable from an activity, | ||
/// which should identify a "parallelism" branch on which the activity executes. | ||
/// Only containers which schedule concurrently (Parallel, ParallelForEach, Pick) | ||
/// would induce a change of the background parallel id. | ||
/// The initial parallel id, before using the above containers, is null. | ||
/// </summary> | ||
public static class ParallelTrackingExtensions | ||
{ | ||
/// <summary> | ||
/// This feature introduces a context.GetCurrentParallelId() queryable from an activity, | ||
/// which should identify a "parallelism" branch on which the activity executes. | ||
/// Only containers which schedule concurrently (Parallel, ParallelForEach, Pick) | ||
/// would induce a change of the background parallel id. | ||
/// The initial parallel id, before using the above containers, is null. | ||
/// </summary> | ||
public static class ParallelTrackingExtensions | ||
{ | ||
public const string BranchIdPropertyName = "__ParallelBranchId"; | ||
public const string BranchIdPropertyName = "__ParallelBranchId"; | ||
|
||
public static ActivityInstance MarkNewParallelBranch(this ActivityInstance instance) | ||
{ | ||
var properties = new ExecutionProperties(null, instance, instance.PropertyManager); | ||
var parentId = properties.Find(BranchIdPropertyName) as string; | ||
properties.Add(BranchIdPropertyName, $"{parentId}.{Guid.NewGuid():N}".Trim('.'), true, false); | ||
public static ActivityInstance MarkNewParallelBranch(this ActivityInstance instance) | ||
{ | ||
var properties = new ExecutionProperties(null, instance, instance.PropertyManager); | ||
var parentId = properties.Find(BranchIdPropertyName) as string; | ||
properties.Add(BranchIdPropertyName, $"{parentId}.{Guid.NewGuid():N}".Trim('.'), true, false); | ||
|
||
return instance; | ||
} | ||
return instance; | ||
} | ||
|
||
public static string GetCurrentParallelBranchId(this ActivityInstance instance) => | ||
instance.PropertyManager?.GetPropertyAtCurrentScope(BranchIdPropertyName) as string; | ||
public static string GetCurrentParallelBranchId(this ActivityInstance instance) => | ||
instance.PropertyManager?.GetPropertyAtCurrentScope(BranchIdPropertyName) as string; | ||
|
||
public static ActivityInstance MarkNewParallelBranch(this ActivityContext context) => | ||
context.CurrentInstance?.MarkNewParallelBranch(); | ||
public static ActivityInstance MarkNewParallelBranch(this ActivityContext context) => | ||
context.CurrentInstance?.MarkNewParallelBranch(); | ||
|
||
public static string GetCurrentParallelBranchId(this ActivityContext context) => | ||
context.CurrentInstance?.GetCurrentParallelBranchId(); | ||
} | ||
public static string GetCurrentParallelBranchId(this ActivityContext context) => | ||
context.CurrentInstance?.GetCurrentParallelBranchId(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters