Skip to content

Commit

Permalink
fix ParallelTracking namespace (#311)
Browse files Browse the repository at this point in the history
Co-authored-by: vuplea <vuplea>
  • Loading branch information
vuplea authored Mar 20, 2024
1 parent 681464d commit 8099ac9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System;
using System.Activities;
using System.Activities.Statements;
using System.Activities.ParallelTracking;
using System.Collections.Generic;
using System.Linq;
using UiPath.Workflow.Runtime.ParallelTracking;
using WorkflowApplicationTestExtensions;
using Xunit;

Expand Down
50 changes: 23 additions & 27 deletions src/UiPath.Workflow.Runtime/ParallelTrackingExtensions.cs
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();
}
2 changes: 1 addition & 1 deletion src/UiPath.Workflow.Runtime/Statements/Parallel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// See LICENSE file in the project root for full license information.

using System.Activities.Runtime.Collections;
using System.Activities.ParallelTracking;
using System.Collections.ObjectModel;
using System.Windows.Markup;
using UiPath.Workflow.Runtime.ParallelTracking;

#if DYNAMICUPDATE
using System.Activities.DynamicUpdate;
Expand Down
2 changes: 1 addition & 1 deletion src/UiPath.Workflow.Runtime/Statements/ParallelForEach.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// This file is part of Core WF which is licensed under the MIT license.
// See LICENSE file in the project root for full license information.

using System.Activities.ParallelTracking;
using System.Collections.ObjectModel;
using System.Windows.Markup;
using UiPath.Workflow.Runtime.ParallelTracking;

#if DYNAMICUPDATE
using System.Activities.DynamicUpdate;
Expand Down
2 changes: 1 addition & 1 deletion src/UiPath.Workflow.Runtime/Statements/Pick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

using System.Activities.Runtime;
using System.Activities.Runtime.Collections;
using System.Activities.ParallelTracking;
using System.Activities.Validation;
using System.Collections.ObjectModel;
using System.Windows.Markup;
using UiPath.Workflow.Runtime.ParallelTracking;

namespace System.Activities.Statements;

Expand Down

0 comments on commit 8099ac9

Please sign in to comment.