CommandSystem 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package CommandSystem --version 1.0.5
                    
NuGet\Install-Package CommandSystem -Version 1.0.5
                    
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="CommandSystem" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CommandSystem" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="CommandSystem" />
                    
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 CommandSystem --version 1.0.5
                    
#r "nuget: CommandSystem, 1.0.5"
                    
#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 CommandSystem@1.0.5
                    
#: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=CommandSystem&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=CommandSystem&version=1.0.5
                    
Install as a Cake Tool

CommandSystem

Add tools for binding classes and methods as string input line for console or input using systems.

Content

Install

Package manager

  • In Visual studion open View Tab;
  • Select in this tab Other windows;
  • Paste code below.
Install-Package CommandSystem -Version 1.0.0

.NET CLI

dotnet add package CommandSystem --version 1.0.0

Packege referance

<PackageReference Include="CommandSystem" Version="1.0.0" />

Set up

using CommandSystem.Routing.Management; 

new RequestRouter().SetManagers(new CommandRoutingManager(), 
    new DirectCommandRoutingManager()).MainLoop();

Using

Name attributes

[Command] attribute
  • Can be used both for class and methods;
  • Has parametrized version [Command(name)];
  • Can be used only once;
  • Is not case-sensative.

Class usage without parameters

  • Uses class name as routing value
  • Can be used once per class
[Command]
public class Calculator
{
    public static int Add(int a, int b)
    {
        return a + b;
    }
}

After that user request calculator will be bind to this class.

Class parameterized [Command(name)] attibute

  • Uses parameter as routing value;
  • If command name is not found uses class name for routing;
  • Can be used once per class.
[Command("Calc")]
public class Calculator
{
    public static int Add(int a, int b)
    {
        return a + b;
    }
}

In this case you may use both Calc and Calculator to direct this class.

Method [Command] without parameters

  • Uses method name to bind method and routing request;
  • Method should be static;
  • Can be used only once per method;
  • Class that contains command-method may have no attributes.
public class DialogRepresenter
{
    [Command]
    public static string Hello(string name)
    {
        return $"Hello, {name}!";
    }
}

In this case hello world has the output will be Hello, world!.

Method [Command(name)] parametrized attribute

  • Uses provided name to bind method and routing request;
  • If provided name is not found in request, uses method name;
  • Method should be static;
  • Can be used only once per method;
  • Class that contains command-method may have no attributes.
public class DialogRepresenter
{
    [Command("Greet")]
    public static string Hello(string name)
    {
        return $"Hello, {name}!";
    }
}

In this case greet world has the output will be Hello, world! the same as hello world.

Warning: You may use overload attribute with this method marked as [Command] but it's not recomended.

[Alias(alias)] attribute
  • Is only parametrized;
  • Can be used both for classes and methods;
  • Can be used multiple times;
  • Do not adds method or class to routing system.
[Command("Calc")]
[Alias("C")]
[Alias("Clc")]
public class Calculator
{
    public static int Add(int a, int b)
    {
        return a + b;
    }
}

Routing requests Calc, C, Clc, Calculator directs to one class.

public class DialogRepresenter
{
    [Command("Greet")]
    [Alias("SayHello")]
    public static string Hello(string name)
    {
        return $"Hello, {name}!";
    }
}

In this case attribute is used for method and routing requests Greet, Say hello and Hello directs to one method.

[Overload] attribute
  • This attribute is used for methods.
  • This methods should be static.
  • Register method as command overload.
  • If name is not provided uses method name for routing

Warning: In тext vesions overload withoud name parameter will not use method name. They will be omit and routing request pattern will be CommandName [parameters].

[Command("Calc")]
[Alias("C")]
[Alias("Clc")]
public class Calculator
{
    [Overload]
    public static int Add(int a, int b)
    {
        return a + b;
    }
}

Adding this attribute alows use Calc add and add parameters after that. For example calc add 5 12 and result will be displayed as 17.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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.
  • net6.0

    • No dependencies.

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.8 644 5/25/2022
1.0.7 528 5/21/2022
1.0.6 541 5/10/2022
1.0.5 555 5/9/2022
1.0.4 548 5/9/2022
1.0.3 524 5/9/2022
1.0.2 528 5/9/2022
1.0.0 573 4/21/2022

Change comparing system