| | | 1 | | using System.Runtime.CompilerServices; |
| | | 2 | | using Elsa.Common; |
| | | 3 | | using Elsa.Expressions.Helpers; |
| | | 4 | | using Elsa.Expressions.Models; |
| | | 5 | | using Elsa.Extensions; |
| | | 6 | | using Elsa.Mediator.Contracts; |
| | | 7 | | using Elsa.Workflows.Exceptions; |
| | | 8 | | using Elsa.Workflows.Memory; |
| | | 9 | | using Elsa.Workflows.Models; |
| | | 10 | | using Elsa.Workflows.Options; |
| | | 11 | | using JetBrains.Annotations; |
| | | 12 | | |
| | | 13 | | namespace Elsa.Workflows; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Represents the context of an activity execution. |
| | | 17 | | /// </summary> |
| | | 18 | | [PublicAPI] |
| | | 19 | | public partial class ActivityExecutionContext : IExecutionContext, IDisposable |
| | | 20 | | { |
| | | 21 | | private readonly ISystemClock _systemClock; |
| | | 22 | | private ActivityStatus _status; |
| | | 23 | | private Exception? _exception; |
| | | 24 | | private long _executionCount; |
| | | 25 | | private ActivityExecutionContext? _parentActivityExecutionContext; |
| | | 26 | | |
| | | 27 | | // Bookmarks created during the lifetime of this activity. |
| | 4028 | 28 | | private List<Bookmark> _newBookmarks = []; |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Initializes a new instance of the <see cref="ActivityExecutionContext"/> class. |
| | | 32 | | /// </summary> |
| | 4028 | 33 | | public ActivityExecutionContext( |
| | 4028 | 34 | | string id, |
| | 4028 | 35 | | WorkflowExecutionContext workflowExecutionContext, |
| | 4028 | 36 | | ActivityExecutionContext? parentActivityExecutionContext, |
| | 4028 | 37 | | IActivity activity, |
| | 4028 | 38 | | ActivityDescriptor activityDescriptor, |
| | 4028 | 39 | | DateTimeOffset startedAt, |
| | 4028 | 40 | | object? tag, |
| | 4028 | 41 | | ISystemClock systemClock, |
| | 4028 | 42 | | CancellationToken cancellationToken) |
| | | 43 | | { |
| | 4028 | 44 | | _systemClock = systemClock; |
| | 4028 | 45 | | Properties = new ChangeTrackingDictionary<string, object>(Taint); |
| | 4028 | 46 | | Metadata = new ChangeTrackingDictionary<string, object>(Taint); |
| | 4028 | 47 | | ActivityState = new ChangeTrackingDictionary<string, object>(Taint); |
| | 4028 | 48 | | ActivityInput = new ChangeTrackingDictionary<string, object>(Taint); |
| | 4028 | 49 | | WorkflowExecutionContext = workflowExecutionContext; |
| | 4028 | 50 | | ParentActivityExecutionContext = parentActivityExecutionContext; |
| | 4028 | 51 | | var expressionExecutionContextProps = ExpressionExecutionContextExtensions.CreateActivityExecutionContextPropert |
| | 4028 | 52 | | expressionExecutionContextProps[ExpressionExecutionContextExtensions.ActivityKey] = activity; |
| | 4028 | 53 | | ExpressionExecutionContext = new(workflowExecutionContext.ServiceProvider, new(), parentActivityExecutionContext |
| | 4028 | 54 | | Activity = activity; |
| | 4028 | 55 | | ActivityDescriptor = activityDescriptor; |
| | 4028 | 56 | | StartedAt = startedAt; |
| | 4028 | 57 | | Status = ActivityStatus.Pending; |
| | 4028 | 58 | | Tag = tag; |
| | 4028 | 59 | | CancellationToken = cancellationToken; |
| | 4028 | 60 | | Id = id; |
| | 4028 | 61 | | _publisher = GetRequiredService<INotificationSender>(); |
| | 4028 | 62 | | } |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// The ID of the current activity execution context. |
| | | 66 | | /// </summary> |
| | 46638 | 67 | | public string Id { get; set; } |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// The time at which the activity execution context was created. |
| | | 71 | | /// </summary> |
| | 8264 | 72 | | public DateTimeOffset StartedAt { get; set; } |
| | | 73 | | |
| | | 74 | | /// <summary> |
| | | 75 | | /// An optional tag to associate with the activity execution. |
| | | 76 | | /// </summary> |
| | 7675 | 77 | | public object? Tag { get; set; } |
| | | 78 | | |
| | | 79 | | /// <summary> |
| | | 80 | | /// The time at which the activity execution context was completed. |
| | | 81 | | /// </summary> |
| | 7638 | 82 | | public DateTimeOffset? CompletedAt { get; set; } |
| | | 83 | | |
| | | 84 | | /// <summary> |
| | | 85 | | /// Returns true if the activity execution context has completed. |
| | | 86 | | /// </summary> |
| | 13425 | 87 | | public bool IsCompleted => Status is ActivityStatus.Completed or ActivityStatus.Canceled; |
| | | 88 | | |
| | | 89 | | /// <summary> |
| | | 90 | | /// Gets or sets a value indicating whether the activity is actively executing. |
| | | 91 | | /// </summary> |
| | | 92 | | /// <remarks> |
| | | 93 | | /// This flag is set to <c>true</c> immediately before the activity begins execution |
| | | 94 | | /// and is set to <c>false</c> once the execution is completed. |
| | | 95 | | /// It can be used to determine if an activity was in-progress in case of unexpected |
| | | 96 | | /// application termination, allowing the system to retry execution upon restarting. |
| | | 97 | | /// </remarks> |
| | 7426 | 98 | | public bool IsExecuting { get; set; } |
| | | 99 | | |
| | | 100 | | /// <summary> |
| | | 101 | | /// The number of faults encountered during the execution of the activity and its descendants. |
| | | 102 | | /// </summary> |
| | 4409 | 103 | | public int AggregateFaultCount { get; set; } |
| | | 104 | | |
| | | 105 | | /// <summary> |
| | | 106 | | /// The workflow execution context. |
| | | 107 | | /// </summary> |
| | 169701 | 108 | | public WorkflowExecutionContext WorkflowExecutionContext { get; } |
| | | 109 | | |
| | | 110 | | /// <summary> |
| | | 111 | | /// The parent activity execution context, if any. |
| | | 112 | | /// This represents the structural container activity (e.g., Flowchart contains all its children). |
| | | 113 | | /// </summary> |
| | | 114 | | public ActivityExecutionContext? ParentActivityExecutionContext |
| | | 115 | | { |
| | 62155 | 116 | | get => _parentActivityExecutionContext; |
| | | 117 | | internal set |
| | | 118 | | { |
| | 4125 | 119 | | _parentActivityExecutionContext = value; |
| | 4125 | 120 | | _parentActivityExecutionContext?.Children.Add(this); |
| | 2966 | 121 | | } |
| | | 122 | | } |
| | | 123 | | |
| | | 124 | | /// <summary> |
| | | 125 | | /// The ID of the activity execution context that scheduled this activity execution. |
| | | 126 | | /// This represents the temporal/execution predecessor that directly triggered execution of this activity, |
| | | 127 | | /// distinct from <see cref="ParentActivityExecutionContext"/> which represents the structural container. |
| | | 128 | | /// For example, in a Flowchart, Activity B might complete and schedule Activity C, making B the scheduling activity |
| | | 129 | | /// </summary> |
| | 7480 | 130 | | public string? SchedulingActivityExecutionId { get; set; } |
| | | 131 | | |
| | | 132 | | /// <summary> |
| | | 133 | | /// The ID of the activity that scheduled this activity execution (denormalized for convenience). |
| | | 134 | | /// This is the Activity.Id from the activity execution context identified by <see cref="SchedulingActivityExecution |
| | | 135 | | /// </summary> |
| | 6236 | 136 | | public string? SchedulingActivityId { get; set; } |
| | | 137 | | |
| | | 138 | | /// <summary> |
| | | 139 | | /// The workflow instance ID of the workflow that scheduled this activity execution. |
| | | 140 | | /// This is set when crossing workflow boundaries (e.g., via ExecuteWorkflow or DispatchWorkflow). |
| | | 141 | | /// For activities within the same workflow instance, this will be null. |
| | | 142 | | /// </summary> |
| | 7449 | 143 | | public string? SchedulingWorkflowInstanceId { get; set; } |
| | | 144 | | |
| | | 145 | | /// <summary> |
| | | 146 | | /// The depth of this activity in the call stack (0 for root activities). |
| | | 147 | | /// </summary> |
| | 9877 | 148 | | public int CallStackDepth { get; set; } |
| | | 149 | | |
| | | 150 | | /// <summary> |
| | | 151 | | /// The expression execution context. |
| | | 152 | | /// </summary> |
| | 45559 | 153 | | public ExpressionExecutionContext ExpressionExecutionContext { get; } |
| | | 154 | | |
| | | 155 | | /// <inheritdoc /> |
| | | 156 | | public IEnumerable<Variable> Variables |
| | | 157 | | { |
| | | 158 | | get |
| | | 159 | | { |
| | 6363 | 160 | | var containerVariables = (Activity as IVariableContainer)?.Variables ?? Enumerable.Empty<Variable>(); |
| | 6363 | 161 | | var dynamicVariables = DynamicVariables; |
| | 6363 | 162 | | var mergedVariables = new Dictionary<string, Variable>(); |
| | | 163 | | |
| | 12998 | 164 | | foreach (var containerVariable in containerVariables) |
| | | 165 | | { |
| | 136 | 166 | | var name = !string.IsNullOrEmpty(containerVariable.Name) ? containerVariable.Name : containerVariable.Id |
| | 136 | 167 | | mergedVariables[name] = containerVariable; |
| | | 168 | | } |
| | | 169 | | |
| | 13096 | 170 | | foreach (var dynamicVariable in dynamicVariables) |
| | | 171 | | { |
| | 185 | 172 | | var name = !string.IsNullOrEmpty(dynamicVariable.Name) ? dynamicVariable.Name : dynamicVariable.Id; |
| | 185 | 173 | | mergedVariables[name] = dynamicVariable; |
| | | 174 | | } |
| | 6363 | 175 | | return mergedVariables.Values; |
| | | 176 | | } |
| | | 177 | | } |
| | | 178 | | |
| | | 179 | | /// <summary> |
| | | 180 | | /// A list of variables that are dynamically added to the activity execution context. |
| | | 181 | | /// </summary> |
| | 11371 | 182 | | public ICollection<Variable> DynamicVariables { get; set; } = new List<Variable>(); |
| | | 183 | | |
| | | 184 | | /// <summary> |
| | | 185 | | /// The currently executing activity. |
| | | 186 | | /// </summary> |
| | 203931 | 187 | | public IActivity Activity { get; set; } |
| | | 188 | | |
| | | 189 | | /// <summary> |
| | | 190 | | /// The activity descriptor. |
| | | 191 | | /// </summary> |
| | 26009 | 192 | | public ActivityDescriptor ActivityDescriptor { get; } |
| | | 193 | | |
| | | 194 | | /// <summary> |
| | | 195 | | /// A cancellation token to use when invoking asynchronous operations. |
| | | 196 | | /// </summary> |
| | 34608 | 197 | | public CancellationToken CancellationToken { get; } |
| | | 198 | | |
| | | 199 | | /// <summary> |
| | | 200 | | /// The current status of the activity. |
| | | 201 | | /// </summary> |
| | | 202 | | public ActivityStatus Status |
| | | 203 | | { |
| | 50042 | 204 | | get => _status; |
| | | 205 | | private set |
| | | 206 | | { |
| | 11406 | 207 | | if (value == _status) |
| | 4066 | 208 | | return; |
| | | 209 | | |
| | 7340 | 210 | | _status = value; |
| | 7340 | 211 | | Taint(); |
| | 7340 | 212 | | } |
| | | 213 | | } |
| | | 214 | | |
| | | 215 | | public IDisposable EnterExecution() |
| | | 216 | | { |
| | 3310 | 217 | | return new WorkflowExecutionState(this); |
| | | 218 | | } |
| | | 219 | | |
| | | 220 | | /// <summary> |
| | | 221 | | /// Sets the current status of the activity. |
| | | 222 | | /// </summary> |
| | | 223 | | public void TransitionTo(ActivityStatus status) |
| | | 224 | | { |
| | 7378 | 225 | | Status = status; |
| | 7378 | 226 | | } |
| | | 227 | | |
| | | 228 | | /// <summary> |
| | | 229 | | /// Gets or sets the exception that occurred during the activity execution, if any. |
| | | 230 | | /// </summary> |
| | | 231 | | public Exception? Exception |
| | | 232 | | { |
| | 3430 | 233 | | get => _exception; |
| | | 234 | | set |
| | | 235 | | { |
| | 39 | 236 | | _exception = value; |
| | 39 | 237 | | Taint(); |
| | 39 | 238 | | } |
| | | 239 | | } |
| | | 240 | | |
| | | 241 | | /// <inheritdoc /> |
| | 13248 | 242 | | public IDictionary<string, object> Properties { get; private set; } |
| | | 243 | | |
| | | 244 | | /// <summary> |
| | | 245 | | /// A transient dictionary of values that can be associated with this activity execution context. |
| | | 246 | | /// These properties only exist while the activity executes and are not persisted. |
| | | 247 | | /// </summary> |
| | 44674 | 248 | | public IDictionary<object, object> TransientProperties { get; set; } = new Dictionary<object, object>(); |
| | | 249 | | |
| | | 250 | | /// <summary> |
| | | 251 | | /// A dictionary of metadata about this execution. In contrast to <see cref="Properties"/>, this metadata is never p |
| | | 252 | | /// </summary> |
| | 8321 | 253 | | public IDictionary<string, object> Metadata { get; private set; } |
| | | 254 | | |
| | | 255 | | /// <summary> |
| | | 256 | | /// Returns the <see cref="ActivityNode"/> metadata about the current activity. |
| | | 257 | | /// </summary> |
| | 32178 | 258 | | public ActivityNode ActivityNode => WorkflowExecutionContext.FindNodeByActivity(Activity)!; |
| | | 259 | | |
| | | 260 | | /// <summary> |
| | | 261 | | /// Returns the global node ID for the current activity within the graph. |
| | | 262 | | /// </summary> |
| | | 263 | | /// <remarks>As of tool version 3.0, all activity IDs are already unique, so there's no need to construct a hierarch |
| | 11138 | 264 | | public string NodeId => ActivityNode.NodeId; |
| | | 265 | | |
| | 14868 | 266 | | public ISet<ActivityExecutionContext> Children { get; } = new HashSet<ActivityExecutionContext>(); |
| | | 267 | | |
| | | 268 | | /// <summary> |
| | | 269 | | /// A list of bookmarks associated with the current activity. |
| | | 270 | | /// </summary> |
| | 3602 | 271 | | public IEnumerable<Bookmark> Bookmarks => WorkflowExecutionContext.Bookmarks.Where(x => x.ActivityInstanceId == Id); |
| | | 272 | | |
| | | 273 | | /// <summary> |
| | | 274 | | /// A collection of bookmarks created during the execution of the activity. |
| | | 275 | | /// </summary> |
| | 698 | 276 | | public IEnumerable<Bookmark> NewBookmarks => _newBookmarks.AsReadOnly(); |
| | | 277 | | |
| | | 278 | | /// <summary> |
| | | 279 | | /// The number of times this <see cref="ActivityExecutionContext"/> has executed. |
| | | 280 | | /// </summary> |
| | 0 | 281 | | public long ExecutionCount => _executionCount; |
| | | 282 | | |
| | | 283 | | /// <summary> |
| | | 284 | | /// A dictionary of received inputs for the current workflow. |
| | | 285 | | /// </summary> |
| | 292 | 286 | | public IDictionary<string, object> WorkflowInput => WorkflowExecutionContext.Input; |
| | | 287 | | |
| | | 288 | | /// <summary> |
| | | 289 | | /// A dictionary of inputs for the current activity. |
| | | 290 | | /// </summary> |
| | 8186 | 291 | | public IDictionary<string, object> ActivityInput { get; private set; } |
| | | 292 | | |
| | | 293 | | /// <summary> |
| | | 294 | | /// Journal data will be added to the workflow execution log for the "Executed" event. |
| | | 295 | | /// </summary> |
| | | 296 | | // ReSharper disable once CollectionNeverQueried.Global |
| | 7605 | 297 | | public IDictionary<string, object> JournalData { get; } = new Dictionary<string, object>(); |
| | | 298 | | |
| | | 299 | | /// <summary> |
| | | 300 | | /// Stores the evaluated inputs, serialized, for the current activity for historical purposes. |
| | | 301 | | /// </summary> |
| | 10456 | 302 | | public IDictionary<string, object> ActivityState { get; } |
| | | 303 | | |
| | | 304 | | /// <summary> |
| | | 305 | | /// Indicates whether the state of the current activity execution context has been modified. |
| | | 306 | | /// </summary> |
| | 34939 | 307 | | public bool IsDirty { get; private set; } |
| | | 308 | | |
| | | 309 | | /// <summary> |
| | | 310 | | /// Schedules the specified activity to be executed. |
| | | 311 | | /// </summary> |
| | | 312 | | /// <param name="activity">The activity to schedule.</param> |
| | | 313 | | /// <param name="completionCallback">An optional callback to invoke when the activity completes.</param> |
| | | 314 | | /// <param name="tag">An optional tag to associate with the activity execution.</param> |
| | | 315 | | /// <param name="variables">An optional list of variables to declare with the activity execution.</param> |
| | | 316 | | public ValueTask ScheduleActivityAsync(IActivity? activity, ActivityCompletionCallback? completionCallback, object? |
| | | 317 | | { |
| | 2133 | 318 | | var options = new ScheduleWorkOptions |
| | 2133 | 319 | | { |
| | 2133 | 320 | | CompletionCallback = completionCallback, |
| | 2133 | 321 | | Tag = tag, |
| | 2133 | 322 | | Variables = variables?.ToList() |
| | 2133 | 323 | | }; |
| | 2133 | 324 | | return ScheduleActivityAsync(activity, options); |
| | | 325 | | } |
| | | 326 | | |
| | | 327 | | /// <summary> |
| | | 328 | | /// Schedules the specified activity to be executed. |
| | | 329 | | /// </summary> |
| | | 330 | | /// <param name="activity">The activity to schedule.</param> |
| | | 331 | | /// <param name="options">The options used to schedule the activity.</param> |
| | | 332 | | public async ValueTask ScheduleActivityAsync(IActivity? activity, ScheduleWorkOptions? options = null) |
| | | 333 | | { |
| | 3044 | 334 | | await ScheduleActivityAsync(activity, this, options); |
| | 3044 | 335 | | } |
| | | 336 | | |
| | | 337 | | /// <summary> |
| | | 338 | | /// Schedules the specified activity to be executed. |
| | | 339 | | /// </summary> |
| | | 340 | | /// <param name="activity">The activity to schedule.</param> |
| | | 341 | | /// <param name="owner">The activity execution context that owns the scheduled activity.</param> |
| | | 342 | | /// <param name="options">The options used to schedule the activity.</param> |
| | | 343 | | public async ValueTask ScheduleActivityAsync(IActivity? activity, ActivityExecutionContext? owner, ScheduleWorkOptio |
| | | 344 | | { |
| | 3044 | 345 | | var schedulerStrategy = GetRequiredService<IActivityExecutionContextSchedulerStrategy>(); |
| | 3044 | 346 | | await schedulerStrategy.ScheduleActivityAsync(this, activity, owner, options); |
| | 3044 | 347 | | } |
| | | 348 | | |
| | | 349 | | /// <summary> |
| | | 350 | | /// Schedules the specified activity to be executed. |
| | | 351 | | /// </summary> |
| | | 352 | | /// <param name="activityNode">The activity node to schedule.</param> |
| | | 353 | | /// <param name="owner">The activity execution context that owns the scheduled activity.</param> |
| | | 354 | | /// <param name="options">The options used to schedule the activity.</param> |
| | | 355 | | public async Task ScheduleActivityAsync(ActivityNode? activityNode, ActivityExecutionContext? owner = null, Schedule |
| | | 356 | | { |
| | 0 | 357 | | var schedulerStrategy = GetRequiredService<IActivityExecutionContextSchedulerStrategy>(); |
| | 0 | 358 | | await schedulerStrategy.ScheduleActivityAsync(this, activityNode, owner, options); |
| | 0 | 359 | | } |
| | | 360 | | |
| | | 361 | | /// <summary> |
| | | 362 | | /// Schedules the specified activities to be executed. |
| | | 363 | | /// </summary> |
| | | 364 | | /// <param name="activities">The activities to schedule.</param> |
| | 0 | 365 | | public async ValueTask ScheduleActivitiesAsync(params IActivity?[] activities) => await ScheduleActivities(activitie |
| | | 366 | | |
| | | 367 | | /// <summary> |
| | | 368 | | /// Schedules the specified activities to be executed. |
| | | 369 | | /// </summary> |
| | | 370 | | /// <param name="activities">The activities to schedule.</param> |
| | | 371 | | /// <param name="completionCallback">The callback to invoke when the activities complete.</param> |
| | | 372 | | /// <param name="tag">An optional tag to associate with the activity execution.</param> |
| | | 373 | | /// <param name="variables">An optional list of variables to declare with the activity execution.</param> |
| | | 374 | | public ValueTask ScheduleActivities(IEnumerable<IActivity?> activities, ActivityCompletionCallback? completionCallba |
| | | 375 | | { |
| | 8 | 376 | | var options = new ScheduleWorkOptions |
| | 8 | 377 | | { |
| | 8 | 378 | | CompletionCallback = completionCallback, |
| | 8 | 379 | | Tag = tag, |
| | 8 | 380 | | Variables = variables?.ToList() |
| | 8 | 381 | | }; |
| | 8 | 382 | | return ScheduleActivities(activities, options); |
| | | 383 | | } |
| | | 384 | | |
| | | 385 | | /// <summary> |
| | | 386 | | /// Schedules the specified activities to be executed. |
| | | 387 | | /// </summary> |
| | | 388 | | /// <param name="activities">The activities to schedule.</param> |
| | | 389 | | /// <param name="options">The options used to schedule the activities.</param> |
| | | 390 | | public async ValueTask ScheduleActivities(IEnumerable<IActivity?> activities, ScheduleWorkOptions? options = null) |
| | | 391 | | { |
| | 48 | 392 | | foreach (var activity in activities) |
| | 16 | 393 | | await ScheduleActivityAsync(activity, options); |
| | 8 | 394 | | } |
| | | 395 | | |
| | | 396 | | /// <summary> |
| | | 397 | | /// Creates a bookmark for each payload. |
| | | 398 | | /// </summary> |
| | | 399 | | /// <param name="payloads">The payloads to create bookmarks for.</param> |
| | | 400 | | /// <param name="callback">An optional callback that is invoked when the bookmark is resumed.</param> |
| | | 401 | | /// <param name="includeActivityInstanceId">Whether or not the activity instance ID should be included in the bookma |
| | | 402 | | /// <param name="bookmarkName">An optional name to use for the bookmark. Defaults to the activity type.</param> |
| | | 403 | | public void CreateBookmarks(IEnumerable<object> payloads, ExecuteActivityDelegate? callback = null, bool includeActi |
| | | 404 | | { |
| | 28 | 405 | | foreach (var payload in payloads) |
| | 7 | 406 | | CreateBookmark(new() |
| | 7 | 407 | | { |
| | 7 | 408 | | Stimulus = payload, |
| | 7 | 409 | | Callback = callback, |
| | 7 | 410 | | BookmarkName = bookmarkName, |
| | 7 | 411 | | IncludeActivityInstanceId = includeActivityInstanceId |
| | 7 | 412 | | }); |
| | 7 | 413 | | } |
| | | 414 | | |
| | | 415 | | /// <summary> |
| | | 416 | | /// Adds each bookmark to the list of bookmarks. |
| | | 417 | | /// </summary> |
| | | 418 | | /// <param name="bookmarks">The bookmarks to add.</param> |
| | | 419 | | public void AddBookmarks(IEnumerable<Bookmark> bookmarks) |
| | | 420 | | { |
| | 0 | 421 | | WorkflowExecutionContext.Bookmarks.AddRange(bookmarks); |
| | 0 | 422 | | Taint(); |
| | 0 | 423 | | } |
| | | 424 | | |
| | | 425 | | /// <summary> |
| | | 426 | | /// Adds a bookmark to the list of bookmarks. |
| | | 427 | | /// </summary> |
| | | 428 | | /// <param name="bookmark">The bookmark to add.</param> |
| | | 429 | | public void AddBookmark(Bookmark bookmark) |
| | | 430 | | { |
| | 74 | 431 | | _newBookmarks.Add(bookmark); |
| | 74 | 432 | | WorkflowExecutionContext.Bookmarks.Add(bookmark); |
| | 74 | 433 | | Taint(); |
| | 74 | 434 | | } |
| | | 435 | | |
| | | 436 | | /// <summary> |
| | | 437 | | /// Creates a bookmark so that this activity can be resumed at a later time. |
| | | 438 | | /// </summary> |
| | | 439 | | /// <param name="callback">An optional callback that is invoked when the bookmark is resumed.</param> |
| | | 440 | | /// <param name="metadata">Custom properties to associate with the bookmark.</param> |
| | | 441 | | /// <returns>The created bookmark.</returns> |
| | | 442 | | public Bookmark CreateBookmark(ExecuteActivityDelegate callback, IDictionary<string, string>? metadata = null) |
| | | 443 | | { |
| | 0 | 444 | | return CreateBookmark(new() |
| | 0 | 445 | | { |
| | 0 | 446 | | Callback = callback, |
| | 0 | 447 | | Metadata = metadata |
| | 0 | 448 | | }); |
| | | 449 | | } |
| | | 450 | | |
| | | 451 | | /// <summary> |
| | | 452 | | /// Creates a bookmark so that this activity can be resumed at a later time. |
| | | 453 | | /// </summary> |
| | | 454 | | /// <param name="stimulus">The payload to associate with the bookmark.</param> |
| | | 455 | | /// <param name="callback">An optional callback that is invoked when the bookmark is resumed.</param> |
| | | 456 | | /// <param name="includeActivityInstanceId">Whether or not the activity instance ID should be included in the bookma |
| | | 457 | | /// <param name="customProperties">Custom properties to associate with the bookmark.</param> |
| | | 458 | | /// <returns>The created bookmark.</returns> |
| | | 459 | | public Bookmark CreateBookmark(object stimulus, ExecuteActivityDelegate? callback, bool includeActivityInstanceId = |
| | | 460 | | { |
| | 0 | 461 | | return CreateBookmark(new() |
| | 0 | 462 | | { |
| | 0 | 463 | | Stimulus = stimulus, |
| | 0 | 464 | | Callback = callback, |
| | 0 | 465 | | IncludeActivityInstanceId = includeActivityInstanceId, |
| | 0 | 466 | | Metadata = customProperties |
| | 0 | 467 | | }); |
| | | 468 | | } |
| | | 469 | | |
| | | 470 | | /// <summary> |
| | | 471 | | /// Creates a bookmark for the current activity execution context. |
| | | 472 | | /// </summary> |
| | | 473 | | /// <param name="stimulus">The payload to associate with the bookmark.</param> |
| | | 474 | | /// <param name="includeActivityInstanceId">Specifies whether to include the activity instance ID in the bookmark in |
| | | 475 | | /// <param name="customProperties">Additional custom properties to associate with the bookmark. Defaults to null.</p |
| | | 476 | | /// <returns>The created bookmark.</returns> |
| | | 477 | | public Bookmark CreateBookmark(object stimulus, bool includeActivityInstanceId, IDictionary<string, string>? customP |
| | | 478 | | { |
| | 0 | 479 | | return CreateBookmark(new() |
| | 0 | 480 | | { |
| | 0 | 481 | | Stimulus = stimulus, |
| | 0 | 482 | | IncludeActivityInstanceId = includeActivityInstanceId, |
| | 0 | 483 | | Metadata = customProperties |
| | 0 | 484 | | }); |
| | | 485 | | } |
| | | 486 | | |
| | | 487 | | /// <summary> |
| | | 488 | | /// Creates a bookmark so that this activity can be resumed at a later time. |
| | | 489 | | /// </summary> |
| | | 490 | | /// <param name="stimulus">The payload to associate with the bookmark.</param> |
| | | 491 | | /// <param name="metadata">Custom properties to associate with the bookmark.</param> |
| | | 492 | | /// <returns>The created bookmark.</returns> |
| | | 493 | | public Bookmark CreateBookmark(object stimulus, IDictionary<string, string>? metadata = null) |
| | | 494 | | { |
| | 13 | 495 | | return CreateBookmark(new() |
| | 13 | 496 | | { |
| | 13 | 497 | | Stimulus = stimulus, |
| | 13 | 498 | | Metadata = metadata |
| | 13 | 499 | | }); |
| | | 500 | | } |
| | | 501 | | |
| | | 502 | | /// <summary> |
| | | 503 | | /// Creates a bookmark so that this activity can be resumed at a later time. |
| | | 504 | | /// Creating a bookmark will automatically suspend the workflow after all pending activities have executed. |
| | | 505 | | /// </summary> |
| | | 506 | | public Bookmark CreateBookmark(CreateBookmarkArgs? options = null) |
| | | 507 | | { |
| | 74 | 508 | | var payload = options?.Stimulus; |
| | 74 | 509 | | var callback = options?.Callback; |
| | 74 | 510 | | var bookmarkName = options?.BookmarkName ?? Activity.Type; |
| | 74 | 511 | | var bookmarkHasher = GetRequiredService<IStimulusHasher>(); |
| | 74 | 512 | | var identityGenerator = GetRequiredService<IIdentityGenerator>(); |
| | 74 | 513 | | var includeActivityInstanceId = options?.IncludeActivityInstanceId ?? true; |
| | 74 | 514 | | var hash = bookmarkHasher.Hash(bookmarkName, payload, includeActivityInstanceId ? Id : null); |
| | 74 | 515 | | var bookmarkId = options?.BookmarkId ?? identityGenerator.GenerateId(); |
| | | 516 | | |
| | 74 | 517 | | var bookmark = new Bookmark( |
| | 74 | 518 | | bookmarkId, |
| | 74 | 519 | | bookmarkName, |
| | 74 | 520 | | hash, |
| | 74 | 521 | | payload, |
| | 74 | 522 | | Activity.Id, |
| | 74 | 523 | | ActivityNode.NodeId, |
| | 74 | 524 | | Id, |
| | 74 | 525 | | _systemClock.UtcNow, |
| | 74 | 526 | | options?.AutoBurn ?? true, |
| | 74 | 527 | | callback?.Method.Name, |
| | 74 | 528 | | options?.AutoComplete ?? true, |
| | 74 | 529 | | options?.Metadata); |
| | | 530 | | |
| | 74 | 531 | | AddBookmark(bookmark); |
| | 74 | 532 | | return bookmark; |
| | | 533 | | } |
| | | 534 | | |
| | | 535 | | /// <summary> |
| | | 536 | | /// Clear all bookmarks. |
| | | 537 | | /// </summary> |
| | | 538 | | public void ClearBookmarks() |
| | | 539 | | { |
| | 3418 | 540 | | _newBookmarks.Clear(); |
| | 3493 | 541 | | WorkflowExecutionContext.Bookmarks.RemoveWhere(x => x.ActivityInstanceId == Id); |
| | 3418 | 542 | | Taint(); |
| | 3418 | 543 | | } |
| | | 544 | | |
| | | 545 | | /// <summary> |
| | | 546 | | /// Returns a property value associated with the current activity context. |
| | | 547 | | /// </summary> |
| | 1620 | 548 | | public T? GetProperty<T>(string key) => Properties.TryGetValue<T?>(key, out var value) ? value : default; |
| | | 549 | | |
| | | 550 | | /// <summary> |
| | | 551 | | /// Returns a property value associated with the current activity context. |
| | | 552 | | /// </summary> |
| | | 553 | | public T GetProperty<T>(string key, Func<T> defaultValue) |
| | | 554 | | { |
| | 136 | 555 | | if (Properties.TryGetValue<T?>(key, out var value)) |
| | 102 | 556 | | return value!; |
| | | 557 | | |
| | 34 | 558 | | value = defaultValue(); |
| | 34 | 559 | | Properties[key] = value!; |
| | | 560 | | |
| | 34 | 561 | | return value!; |
| | | 562 | | } |
| | | 563 | | |
| | | 564 | | /// <summary> |
| | | 565 | | /// Stores a property associated with the current activity context. |
| | | 566 | | /// </summary> |
| | 166 | 567 | | public void SetProperty<T>(string key, T? value) => Properties[key] = value!; |
| | | 568 | | |
| | | 569 | | /// <summary> |
| | | 570 | | /// Updates a property associated with the current activity context. |
| | | 571 | | /// </summary> |
| | | 572 | | public T UpdateProperty<T>(string key, Func<T?, T> updater) where T : notnull |
| | | 573 | | { |
| | 376 | 574 | | var value = GetProperty<T?>(key); |
| | 376 | 575 | | value = updater(value); |
| | 376 | 576 | | Properties[key] = value; |
| | 376 | 577 | | return value; |
| | | 578 | | } |
| | | 579 | | |
| | | 580 | | /// <summary> |
| | | 581 | | /// Removes a property associated with the current activity context. |
| | | 582 | | /// </summary> |
| | | 583 | | /// <param name="key">The property key.</param> |
| | 0 | 584 | | public void RemoveProperty(string key) => Properties.Remove(key); |
| | | 585 | | |
| | | 586 | | /// <summary> |
| | | 587 | | /// Returns a metadata value associated with the current activity context. |
| | | 588 | | /// </summary> |
| | 0 | 589 | | public T? GetMetadata<T>(string key) => Metadata.TryGetValue<T?>(key, out var value) ? value : default; |
| | | 590 | | |
| | | 591 | | /// <summary> |
| | | 592 | | /// Returns a metadata value associated with the current activity context. |
| | | 593 | | /// </summary> |
| | | 594 | | public T GetMetadata<T>(string key, Func<T> defaultValue) |
| | | 595 | | { |
| | 30 | 596 | | if (Metadata.TryGetValue<T?>(key, out var value)) |
| | 13 | 597 | | return value!; |
| | | 598 | | |
| | 17 | 599 | | value = defaultValue(); |
| | 17 | 600 | | Metadata[key] = value!; |
| | | 601 | | |
| | 17 | 602 | | return value!; |
| | | 603 | | } |
| | | 604 | | |
| | | 605 | | /// <summary> |
| | | 606 | | /// Stores a metadata value associated with the current activity context. |
| | | 607 | | /// </summary> |
| | 4 | 608 | | public void SetMetadata<T>(string key, T? value) => Metadata[key] = value!; |
| | | 609 | | |
| | | 610 | | /// <summary> |
| | | 611 | | /// Updates a metadata value associated with the current activity context. |
| | | 612 | | /// </summary> |
| | | 613 | | public T UpdateMetadata<T>(string key, Func<T?, T> updater) where T : notnull |
| | | 614 | | { |
| | 0 | 615 | | var value = GetMetadata<T?>(key); |
| | 0 | 616 | | value = updater(value); |
| | 0 | 617 | | Metadata[key] = value; |
| | 0 | 618 | | return value; |
| | | 619 | | } |
| | | 620 | | |
| | | 621 | | /// <summary> |
| | | 622 | | /// Removes a metadata value associated with the current activity context. |
| | | 623 | | /// </summary> |
| | | 624 | | /// <param name="key">The metadata key.</param> |
| | 0 | 625 | | public void RemoveMetadata(string key) => Metadata.Remove(key); |
| | | 626 | | |
| | | 627 | | /// <summary> |
| | | 628 | | /// Resolves a required service using the service provider. |
| | | 629 | | /// </summary> |
| | | 630 | | /// <typeparam name="T">The service type.</typeparam> |
| | | 631 | | /// <returns>The resolved service.</returns> |
| | 33728 | 632 | | public T GetRequiredService<T>() where T : notnull => WorkflowExecutionContext.GetRequiredService<T>(); |
| | | 633 | | |
| | | 634 | | /// <summary> |
| | | 635 | | /// Resolves a required service using the service provider. |
| | | 636 | | /// </summary> |
| | | 637 | | /// <param name="serviceType">The service type.</param> |
| | | 638 | | /// <returns>The resolved service.</returns> |
| | 3021 | 639 | | public object GetRequiredService(Type serviceType) => WorkflowExecutionContext.GetRequiredService(serviceType); |
| | | 640 | | |
| | | 641 | | /// <summary> |
| | | 642 | | /// Resolves a service using the service provider. If not found, a new instance is created. |
| | | 643 | | /// </summary> |
| | | 644 | | /// <typeparam name="T">The service type.</typeparam> |
| | | 645 | | /// <returns>The resolved service.</returns> |
| | 0 | 646 | | public T GetOrCreateService<T>() where T : notnull => WorkflowExecutionContext.GetOrCreateService<T>(); |
| | | 647 | | |
| | | 648 | | /// <summary> |
| | | 649 | | /// Resolves a service using the service provider. If not found, a new instance is created. |
| | | 650 | | /// </summary> |
| | | 651 | | /// <param name="serviceType">The service type.</param> |
| | | 652 | | /// <returns>The resolved service.</returns> |
| | 0 | 653 | | public object GetOrCreateService(Type serviceType) => WorkflowExecutionContext.GetOrCreateService(serviceType); |
| | | 654 | | |
| | | 655 | | /// <summary> |
| | | 656 | | /// Resolves a service using the service provider. |
| | | 657 | | /// </summary> |
| | | 658 | | /// <typeparam name="T">The service type.</typeparam> |
| | | 659 | | /// <returns>The resolved service.</returns> |
| | 593 | 660 | | public T? GetService<T>() where T : notnull => WorkflowExecutionContext.GetService<T>(); |
| | | 661 | | |
| | | 662 | | /// <summary> |
| | | 663 | | /// Resolves all services of the specified type using the service provider. |
| | | 664 | | /// </summary> |
| | | 665 | | /// <typeparam name="T">The service type.</typeparam> |
| | | 666 | | /// <returns>The resolved services.</returns> |
| | 263 | 667 | | public IEnumerable<T> GetServices<T>() where T : notnull => WorkflowExecutionContext.GetServices<T>(); |
| | | 668 | | |
| | | 669 | | /// <summary> |
| | | 670 | | /// Resolves a service using the service provider. |
| | | 671 | | /// </summary> |
| | | 672 | | /// <param name="serviceType">The service type.</param> |
| | | 673 | | /// <returns>The resolved service.</returns> |
| | 0 | 674 | | public object? GetService(Type serviceType) => WorkflowExecutionContext.GetService(serviceType); |
| | | 675 | | |
| | | 676 | | /// <summary> |
| | | 677 | | /// Gets the value of the specified input. |
| | | 678 | | /// </summary> |
| | | 679 | | /// <param name="input">The input.</param> |
| | | 680 | | /// <typeparam name="T">The type of the input.</typeparam> |
| | | 681 | | /// <returns>The input value.</returns> |
| | 3116 | 682 | | public T? Get<T>(Input<T>? input) => input == null ? default : Get<T>(input.MemoryBlockReference()); |
| | | 683 | | |
| | | 684 | | /// <summary> |
| | | 685 | | /// Gets the value of the specified output. |
| | | 686 | | /// </summary> |
| | | 687 | | /// <param name="output">The output.</param> |
| | | 688 | | /// <typeparam name="T">The type of the output.</typeparam> |
| | | 689 | | /// <returns>The output value.</returns> |
| | 0 | 690 | | public T? Get<T>(Output<T>? output) => output == null ? default : Get<T>(output.MemoryBlockReference()); |
| | | 691 | | |
| | | 692 | | /// <summary> |
| | | 693 | | /// Gets the value of the specified output. |
| | | 694 | | /// </summary> |
| | | 695 | | /// <param name="output">The output.</param> |
| | | 696 | | /// <returns>The output value.</returns> |
| | 4 | 697 | | public object? Get(Output? output) => output == null ? null : Get(output.MemoryBlockReference()); |
| | | 698 | | |
| | | 699 | | /// <summary> |
| | | 700 | | /// Gets the value of the specified memory block. |
| | | 701 | | /// </summary> |
| | | 702 | | /// <param name="blockReference">The memory block reference.</param> |
| | | 703 | | /// <returns>The memory block value.</returns> |
| | | 704 | | /// <exception cref="InvalidOperationException">The memory block does not exist.</exception> |
| | | 705 | | public object? Get(MemoryBlockReference blockReference) |
| | | 706 | | { |
| | 2245 | 707 | | return !TryGet(blockReference, out var value) |
| | 2245 | 708 | | ? throw new InvalidOperationException($"The memory block '{blockReference}' does not exist.") |
| | 2245 | 709 | | : value; |
| | | 710 | | } |
| | | 711 | | |
| | | 712 | | /// <summary> |
| | | 713 | | /// Gets the value of the specified memory block. |
| | | 714 | | /// </summary> |
| | | 715 | | /// <param name="blockReference">The memory block reference.</param> |
| | | 716 | | /// <typeparam name="T">The type of the memory block.</typeparam> |
| | | 717 | | /// <returns>The memory block value.</returns> |
| | | 718 | | public T? Get<T>(MemoryBlockReference blockReference) |
| | | 719 | | { |
| | 2118 | 720 | | var value = Get(blockReference); |
| | 2118 | 721 | | return value != null ? value.ConvertTo<T>() : default; |
| | | 722 | | } |
| | | 723 | | |
| | | 724 | | /// <summary> |
| | | 725 | | /// Tries to get the value of the specified memory block. |
| | | 726 | | /// </summary> |
| | | 727 | | /// <param name="blockReference">The memory block reference.</param> |
| | | 728 | | /// <param name="value">The memory block value.</param> |
| | | 729 | | /// <returns>True if the memory block exists, false otherwise.</returns> |
| | | 730 | | public bool TryGet(MemoryBlockReference blockReference, out object? value) |
| | | 731 | | { |
| | | 732 | | // First, try to get the value from the memory register |
| | 2426 | 733 | | var memoryBlock = GetMemoryBlock(blockReference); |
| | | 734 | | |
| | 2426 | 735 | | if (memoryBlock != null) |
| | | 736 | | { |
| | 2423 | 737 | | value = memoryBlock.Value; |
| | 2423 | 738 | | return true; |
| | | 739 | | } |
| | | 740 | | |
| | | 741 | | // Handle Literal references as a fallback - they can hold their value directly |
| | 3 | 742 | | if (blockReference is Literal literal) |
| | | 743 | | { |
| | 3 | 744 | | value = literal.Value; |
| | 3 | 745 | | return true; |
| | | 746 | | } |
| | | 747 | | |
| | 0 | 748 | | value = null; |
| | 0 | 749 | | return false; |
| | | 750 | | } |
| | | 751 | | |
| | | 752 | | /// <summary> |
| | | 753 | | /// Sets a value at the specified memory block. |
| | | 754 | | /// </summary> |
| | | 755 | | /// <param name="blockReference">The memory block reference.</param> |
| | | 756 | | /// <param name="value">The value to set.</param> |
| | | 757 | | /// <param name="configure">An optional callback that can be used to configure the memory block.</param> |
| | 6 | 758 | | public void Set(MemoryBlockReference blockReference, object? value, Action<MemoryBlock>? configure = null) => Expres |
| | | 759 | | |
| | | 760 | | /// <summary> |
| | | 761 | | /// Sets a value at the specified output. |
| | | 762 | | /// </summary> |
| | | 763 | | /// <param name="output">The output.</param> |
| | | 764 | | /// <param name="value">The value to set.</param> |
| | | 765 | | /// <param name="outputName">The name of the output.</param> |
| | | 766 | | /// <typeparam name="T">The type of the output.</typeparam> |
| | 1690 | 767 | | public void Set<T>(Output<T>? output, T? value, [CallerArgumentExpression("output")] string? outputName = null) => S |
| | | 768 | | |
| | | 769 | | /// <summary> |
| | | 770 | | /// Sets a value at the specified output. |
| | | 771 | | /// </summary> |
| | | 772 | | /// <param name="output">The output.</param> |
| | | 773 | | /// <param name="value">The value to set.</param> |
| | | 774 | | /// <param name="outputName">The name of the output.</param> |
| | | 775 | | public void Set(Output? output, object? value, [CallerArgumentExpression("output")] string? outputName = null) |
| | | 776 | | { |
| | 1718 | 777 | | if (output?.Converter == null) |
| | | 778 | | { |
| | | 779 | | // Store the value in the expression execution memory block. |
| | 1710 | 780 | | ExpressionExecutionContext.Set(output, value); |
| | | 781 | | |
| | | 782 | | // Also store the value in the workflow execution transient activity output register. |
| | 1710 | 783 | | WorkflowExecutionContext.RecordActivityOutput(this, outputName, value); |
| | 1710 | 784 | | return; |
| | | 785 | | } |
| | | 786 | | |
| | 16 | 787 | | var descriptor = ActivityDescriptor.Outputs.FirstOrDefault(x => x.PropertyInfo?.Name == outputName); |
| | 8 | 788 | | descriptor ??= ActivityDescriptor.Outputs.FirstOrDefault(x => x.ValueGetter != null && ReferenceEquals(x.ValueGe |
| | 8 | 789 | | var resolvedOutputName = descriptor?.Name ?? outputName ?? ActivityOutputRegister.DefaultOutputName; |
| | 8 | 790 | | var sourceType = descriptor?.Type ?? GetOutputValueType(output.GetType()) ?? typeof(object); |
| | | 791 | | |
| | | 792 | | // The activity output register always retains the activity's native value. |
| | 8 | 793 | | WorkflowExecutionContext.RecordActivityOutput(this, outputName, value); |
| | | 794 | | |
| | 8 | 795 | | var destinationResolver = GetRequiredService<IOutputBindingDestinationResolver>(); |
| | 8 | 796 | | var destination = destinationResolver.Resolve(this, output); |
| | | 797 | | |
| | 8 | 798 | | if (destination == null) |
| | | 799 | | { |
| | 0 | 800 | | throw new OutputConversionException( |
| | 0 | 801 | | output.Converter.Id, |
| | 0 | 802 | | OutputConversionFailureStage.Resolution, |
| | 0 | 803 | | Activity.Id, |
| | 0 | 804 | | Activity.Type, |
| | 0 | 805 | | resolvedOutputName, |
| | 0 | 806 | | output.MemoryBlockReference().Id, |
| | 0 | 807 | | sourceType, |
| | 0 | 808 | | null); |
| | | 809 | | } |
| | | 810 | | |
| | 8 | 811 | | if (value == null) |
| | | 812 | | { |
| | 2 | 813 | | if (!destination.AllowsNull) |
| | | 814 | | { |
| | 1 | 815 | | throw new OutputConversionException( |
| | 1 | 816 | | output.Converter.Id, |
| | 1 | 817 | | OutputConversionFailureStage.ResultValidation, |
| | 1 | 818 | | Activity.Id, |
| | 1 | 819 | | Activity.Type, |
| | 1 | 820 | | resolvedOutputName, |
| | 1 | 821 | | destination.Id, |
| | 1 | 822 | | sourceType, |
| | 1 | 823 | | destination.Type); |
| | | 824 | | } |
| | | 825 | | |
| | 1 | 826 | | ExpressionExecutionContext.SetBoundValue(output, null); |
| | 1 | 827 | | return; |
| | | 828 | | } |
| | | 829 | | |
| | 6 | 830 | | var converterInvoker = GetRequiredService<IOutputConverterInvoker>(); |
| | 6 | 831 | | var convertedValue = converterInvoker.Invoke(this, output, resolvedOutputName, sourceType, value, destination); |
| | 4 | 832 | | ExpressionExecutionContext.SetBoundValue(output, convertedValue); |
| | 4 | 833 | | } |
| | | 834 | | |
| | | 835 | | private static Type? GetOutputValueType(Type outputType) |
| | | 836 | | { |
| | 0 | 837 | | for (var currentType = outputType; currentType != null; currentType = currentType.BaseType) |
| | | 838 | | { |
| | 0 | 839 | | if (currentType.IsGenericType && currentType.GetGenericTypeDefinition() == typeof(Output<>)) |
| | 0 | 840 | | return currentType.GenericTypeArguments[0]; |
| | | 841 | | } |
| | | 842 | | |
| | 0 | 843 | | return null; |
| | | 844 | | } |
| | | 845 | | |
| | | 846 | | /// <summary> |
| | | 847 | | /// Removes all completion callbacks for the current activity. |
| | | 848 | | /// </summary> |
| | | 849 | | public void ClearCompletionCallbacks() |
| | | 850 | | { |
| | 4957 | 851 | | var entriesToRemove = WorkflowExecutionContext.CompletionCallbacks.Where(x => x.Owner == this).ToList(); |
| | 3418 | 852 | | WorkflowExecutionContext.RemoveCompletionCallbacks(entriesToRemove); |
| | 3418 | 853 | | } |
| | | 854 | | |
| | | 855 | | public void Taint() |
| | | 856 | | { |
| | 17393 | 857 | | if (!IsDirty) |
| | 3950 | 858 | | IsDirty = true; |
| | 17393 | 859 | | } |
| | | 860 | | |
| | | 861 | | public void ClearTaint() |
| | | 862 | | { |
| | 3399 | 863 | | if (IsDirty) |
| | 3399 | 864 | | IsDirty = false; |
| | 3399 | 865 | | } |
| | | 866 | | |
| | | 867 | | internal void IncrementExecutionCount() |
| | | 868 | | { |
| | 3296 | 869 | | _executionCount++; |
| | 3296 | 870 | | } |
| | | 871 | | |
| | | 872 | | private MemoryBlock? GetMemoryBlock(MemoryBlockReference locationBlockReference) |
| | | 873 | | { |
| | 2426 | 874 | | return ExpressionExecutionContext.TryGetBlock(locationBlockReference, out var memoryBlock) ? memoryBlock : null; |
| | | 875 | | } |
| | | 876 | | |
| | | 877 | | void IDisposable.Dispose() |
| | | 878 | | { |
| | 0 | 879 | | } |
| | | 880 | | } |