LexBus 1.0.2

dotnet add package LexBus --version 1.0.2
                    
NuGet\Install-Package LexBus -Version 1.0.2
                    
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="LexBus" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LexBus" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="LexBus" />
                    
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 LexBus --version 1.0.2
                    
#r "nuget: LexBus, 1.0.2"
                    
#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 LexBus@1.0.2
                    
#: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=LexBus&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=LexBus&version=1.0.2
                    
Install as a Cake Tool

LexBus

Quick Start

using LexBus.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddHttpClient();
builder.Services.AddSingleton<Demo>();

builder.Services.AddLexBus(options =>
{
    options.HostOfRabbit = "your.rabbit.server";
    options.PortOfRabbit = 5672;
    options.UserOfRabbit = "user";
    options.PasswordOfRabbit = "password";

    options.AddBus<int>("device.int");
    options.AddBus<long>("device.long");
    options.AddBus<Mark>("device.mark");
});

var app = builder.Build();

// Configure the HTTP request pipeline.

app.UseLexBus();

app.Start();

//all registed buses,communicate through the serverid
var intBus = app.Services.GetService<LexBus.Bus.IShellBus<int>>();
var longBus = app.Services.GetService<LexBus.Bus.IShellBus<long>>();
var markBus = app.Services.GetService<LexBus.Bus.IShellBus<Mark>>();

//1. by bus call shell.
//result:{"Code":1,"DataType":3,"Message":"Successful","Data":"Func"}
var resultByBus = intBus.CallAsync("device.int", "demo call -arg2 1", CancellationToken.None).Result;

//2. by http call shell. target serverid uri:http://localhost:5174
var factory = app.Services.GetService<IHttpClientFactory>();
var http = factory.CreateClient();

http.DefaultRequestHeaders.Add("shell-secret", "blymonix");

var content = new StringContent("demo call2 call3 call4");

//result:{"Code":1,"DataType":3,"Message":"Successful","Data":"Funcs"}
var resultByHttp = http.PostAsync("http://localhost:5174/shell", content)
    .Result.Content.ReadFromJsonAsync<LexBus.Shell.ShellExecutedResult>().Result;

Console.ReadKey();

[LexBus.Attributes.Shell]
public class Demo
{
    [LexBus.Attributes.Tag("tag")]
    [LexBus.Attributes.Group("group")]
    [LexBus.Attributes.Command("demo", "call")]
    [LexBus.Attributes.Argument("arg1", "desc")]
    [LexBus.Attributes.Argument("arg2", "desc", required: true)]
    public ValueTask<LexBus.Shell.ShellExecutedResult> Func(LexBus.Shell.ShellExecutingContext context)
    {
        if (context.TryGetArgument("arg1", out var arg1Span))
        {
            //it may not exist
        }

        if (context.TryGetArgument("arg2", out var arg2Span))
        {
            //it must exist
        }

        return new ValueTask<LexBus.Shell.ShellExecutedResult>(LexBus.Shell.ShellExecutedResult.ByText("Func"));
    }

    [LexBus.Attributes.Tag("tag")]
    [LexBus.Attributes.Group("group")]
    [LexBus.Attributes.Command("demo", "call1")]
    public Task<LexBus.Shell.ShellExecutedResult> Func1(LexBus.Shell.ShellExecutingContext context)
    {
        return Task.FromResult(LexBus.Shell.ShellExecutedResult.ByText("Func1"));
    }

    [LexBus.Attributes.Tag("tag")]
    [LexBus.Attributes.Group("group")]
    [LexBus.Attributes.Command("demo", "call2", "call3", "call4")]
    public LexBus.Shell.ShellExecutedResult Func2(LexBus.Shell.ShellExecutingContext context)
    {
        return LexBus.Shell.ShellExecutedResult.ByText("Funcs");
    }
}

public class Mark { }
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
1.0.2 125 5/9/2026
1.0.1 117 5/8/2026
1.0.0 113 5/8/2026

update LexBus.Generator version