Skip to content

wuxinheng/Cheerful

Repository files navigation

Cheerful

Codacy Badge Codacy Badge build release CodeQL

📦 安装

  • 从 Nuget 直接安装
dotnet add package Cheerful --version xxx

🌈用法

public class TestContext
{
    public TestContext(int a, int r)
    {
        A = a;
        R = r;
    }

    public int A { get; set; }
    public int R { get; set; }
}
public class TestPipeLineService1 : PipeLineService<TestContext>
{
    public override void Invoke(TestContext t)
    {
        t.A++;
        NextService?.Invoke(t);
        t.R--;
    }
}
internal class Program
{
    static void Main(string[] args)
    {
        var context = new TestContext(0, 10);
        var pipeLine = new PipeLine<TestContext>();
        pipeLine.Add<TestPipeLineService1>();
        pipeLine.Add<TestPipeLineService1>();
        pipeLine.Add<TestPipeLineService1>();
        pipeLine.Add<TestPipeLineService1>();
        pipeLine.Add<TestPipeLineService1>();
        pipeLine.Add<TestPipeLineService1>();
        pipeLine.Invoke(context);
        Console.WriteLine(context.A); // 6
        Console.WriteLine(context.R); //4
    }
}

📰 许可证(License)

License

About

Accumulated basic code in their own work, to avoid repeated wheel building.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages