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" />
<PackageReference Include="LexBus" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=LexBus&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.
-
net10.0
- LexBus.Generator (>= 1.0.1)
- Microsoft.AspNetCore.Http (>= 2.3.9)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.7)
- RabbitMQ.Client (>= 7.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
update LexBus.Generator version