< Summary

Information
Class: Elsa.Workflows.IActivityRegistry
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Contracts/IActivityRegistry.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 121
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
EnsureDescriptorsAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Contracts/IActivityRegistry.cs

#LineLine coverage
 1using System.Diagnostics.CodeAnalysis;
 2using Elsa.Workflows.Models;
 3
 4namespace Elsa.Workflows;
 5
 6/// <summary>
 7/// Stores all activity descriptors available to the system.
 8/// </summary>
 9public interface IActivityRegistry : IActivityProvider
 10{
 11    /// <summary>
 12    /// Adds an activity descriptor to the registry.
 13    /// </summary>
 14    /// <param name="providerType">The type of the activity provider.</param>
 15    /// <param name="descriptor">The activity descriptor to add.</param>
 16    void Add(Type providerType, ActivityDescriptor descriptor);
 17
 18    /// <summary>
 19    /// Removes an activity descriptor from the registry.
 20    /// </summary>
 21    /// <param name="providerType">The type of the activity provider.</param>
 22    /// <param name="descriptor">The activity descriptor to remove.</param>
 23    void Remove(Type providerType, ActivityDescriptor descriptor);
 24
 25    /// <summary>
 26    /// Returns all activity descriptors in the registry.
 27    /// </summary>
 28    /// <returns>All activity descriptors in the registry.</returns>
 29    IEnumerable<ActivityDescriptor> ListAll();
 30
 31    /// <summary>
 32    /// Returns all activity descriptors provided by the specified provider.
 33    /// </summary>
 34    /// <param name="providerType">The type of the activity provider.</param>
 35    /// <returns>All activity descriptors provided by the specified provider.</returns>
 36    IEnumerable<ActivityDescriptor> ListByProvider(Type providerType);
 37
 38    /// <summary>
 39    /// Returns the activity descriptor for the specified activity type.
 40    /// </summary>
 41    /// <param name="type">The activity type.</param>
 42    /// <returns>The activity descriptor for the specified activity type.</returns>
 43    ActivityDescriptor? Find(string type);
 44
 45    /// <summary>
 46    /// Returns the activity descriptor for the specified activity type and version.
 47    /// </summary>
 48    /// <param name="type">The activity type.</param>
 49    /// <param name="version">The activity version.</param>
 50    /// <returns>The activity descriptor for the specified activity type and version.</returns>
 51    ActivityDescriptor? Find(string type, int version);
 52
 53    /// <summary>
 54    /// Returns the activity descriptor matching the specified predicate.
 55    /// </summary>
 56    /// <param name="predicate">The predicate to match.</param>
 57    /// <returns>The activity descriptor matching the specified predicate.</returns>
 58    ActivityDescriptor? Find(Func<ActivityDescriptor, bool> predicate);
 59
 60    /// <summary>
 61    /// Returns all activity descriptors matching the specified predicate.
 62    /// </summary>
 63    /// <param name="predicate">The predicate to match.</param>
 64    /// <returns>All activity descriptors matching the specified predicate.</returns>
 65    IEnumerable<ActivityDescriptor> FindMany(Func<ActivityDescriptor, bool> predicate);
 66
 67    /// <summary>
 68    /// Registers an activity descriptor.
 69    /// </summary>
 70    /// <param name="descriptor">The activity descriptor to register.</param>
 71    void Register(ActivityDescriptor descriptor);
 72
 73    /// <summary>
 74    /// Registers an activity type.
 75    /// </summary>
 76    /// <param name="activityType">The activity type to register.</param>
 77    /// <param name="cancellationToken">An optional cancellation token.</param>
 78    Task RegisterAsync([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type activityType, 
 79
 80    /// <summary>
 81    /// Registers multiple activity types.
 82    /// </summary>
 83    /// <param name="activityTypes">The activity types to register.</param>
 84    /// <param name="cancellationToken">An optional cancellation token.</param>
 85    Task RegisterAsync(IEnumerable<Type> activityTypes, CancellationToken cancellationToken = default);
 86
 87    /// <summary>
 88    /// Refreshes the activity descriptors in the registry by querying the specified activity providers.
 89    /// </summary>
 90    /// <param name="activityProviders">The activity providers used to retrieve the descriptors.</param>
 91    /// <param name="cancellationToken">The cancellation token.</param>
 92    /// <returns>A task representing the asynchronous operation.</returns>
 93    Task RefreshDescriptorsAsync(IEnumerable<IActivityProvider> activityProviders, CancellationToken cancellationToken =
 94
 95    /// <summary>
 96    /// Refreshes the activity descriptors in the registry by querying the specified activity provider.
 97    /// </summary>
 98    Task RefreshDescriptorsAsync(IActivityProvider activityProvider, CancellationToken cancellationToken = default);
 99
 100    /// <summary>
 101    /// Ensures that descriptors from a tenant-agnostic activity provider have been initialized.
 102    /// </summary>
 103    /// <param name="activityProvider">The activity provider used to retrieve the descriptors.</param>
 104    /// <param name="cancellationToken">The cancellation token.</param>
 105    /// <remarks>
 106    /// Tenant-sensitive providers are refreshed on every call. The default implementation refreshes every provider to p
 107    /// </remarks>
 108    Task EnsureDescriptorsAsync(IActivityProvider activityProvider, CancellationToken cancellationToken = default) =>
 0109        RefreshDescriptorsAsync(activityProvider, cancellationToken);
 110
 111    /// <summary>
 112    /// Clears all activity descriptors from the registry.
 113    /// </summary>
 114    void Clear();
 115
 116    /// <summary>
 117    /// Clears all activity descriptors provided by the specified provider.
 118    /// </summary>
 119    /// <param name="providerType">The type of the activity provider.</param>
 120    void ClearProvider(Type providerType);
 121}