MeshWeaver.Activities 2.1.0

dotnet add package MeshWeaver.Activities --version 2.1.0
                    
NuGet\Install-Package MeshWeaver.Activities -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MeshWeaver.Activities" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MeshWeaver.Activities" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MeshWeaver.Activities" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MeshWeaver.Activities --version 2.1.0
                    
#r "nuget: MeshWeaver.Activities, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MeshWeaver.Activities@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MeshWeaver.Activities&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MeshWeaver.Activities&version=2.1.0
                    
Install as a Cake Tool

MeshWeaver.Activities

MeshWeaver.Activities implements the activity tracking framework defined in MeshWeaver.Activities.Contract. It provides concrete implementations for activity monitoring, logging, and sub-activity management.

Overview

The library provides:

  • Implementation of IActivity interface
  • Activity lifecycle management
  • Sub-activity tracking
  • Integration with message hub system

Implementation

Activity Class

public class Activity : IActivity
{
    private readonly IMessageHub _messageHub;
    private readonly IDictionary<string, ActivityLog> _subActivities;

    public Activity(string name, IMessageHub messageHub)
    {
        Name = name;
        _messageHub = messageHub;
    }

    public string Name { get; }

    public IActivity StartSubActivity(string name)
    {
        // Creates and tracks a new sub-activity
        return new Activity(name, _messageHub);
    }

    public void LogInformation(string message)
    {
        // Logs activity information through message hub
    }

    public async Task<ActivityLog> Complete(Action<ActivityLog> onComplete = null)
    {
        // Completes the activity and all sub-activities
        var log = new ActivityLog
        {
            Status = ActivityStatus.Succeeded,
            SubActivities = _subActivities
        };
        
        onComplete?.Invoke(log);
        return log;
    }
}

Usage Examples

Basic Activity Tracking

// Create and use an activity
var activity = new Activity("MyActivity", messageHub);
activity.LogInformation("Processing started");
await activity.Complete();

Hierarchical Activities

// Main activity with sub-activities
var activity = new Activity("MainProcess", messageHub);
var subActivity1 = activity.StartSubActivity("SubProcess1");
var subActivity2 = activity.StartSubActivity("SubProcess2");

// Log information in different activities
activity.LogInformation("Main process running");
subActivity1.LogInformation("Sub-process 1 running");
subActivity2.LogInformation("Sub-process 2 running");

// Complete sub-activities
await subActivity1.Complete();
await subActivity2.Complete();

// Complete main activity
await activity.Complete(log => 
{
    // Access completion information
    var subActivities = log.SubActivities;
});

Auto-Completion Support

var activity = new Activity("AutoComplete", messageHub);
var subActivity = activity.StartSubActivity("SubProcess");

// Start completion of main activity
var completionTask = activity.Complete();

// Complete sub-activity - main activity will complete automatically
await subActivity.Complete();

Features

  1. Activity Management

    • Creation and tracking of activities
    • Hierarchical activity structure
    • Automatic sub-activity management
  2. Logging

    • Activity status tracking
    • Information logging
    • Completion state management
  3. Message Hub Integration

    • Activity events broadcasting
    • Message-based logging
    • Cross-component communication
  • MeshWeaver.Activities.Contract - Core activity interfaces
  • MeshWeaver.Import - Import functionality using activities
  • MeshWeaver.Data - Data management with activity tracking
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 432 4/6/2025
2.0.3 706 3/24/2025
2.0.2 715 3/24/2025
2.0.1 362 3/21/2025
2.0.0 395 3/20/2025
2.0.0-preview3 339 2/28/2025
2.0.0-Preview2 383 2/10/2025
2.0.0-preview1 372 1/6/2025
1.0.1 339 10/8/2024
1.0.0 339 10/8/2024