CI / Go Backend (push) Canceled after 0s
初始化 monorepo: Go后端(7微服务) + Unity客户端(9模块) + 启动器 HTML5原型: Three.js 3D体素世界, Perlin噪声地形, 原版材质, 22种方块 Minecraft创造模式背包: 双栏布局, 拖拽移动物品, 方向性元件引脚 AI助搭策划文档 + 客户端/服务端骨架 + Docker Compose + CI
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Immutable;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PCL.Core.App.IoC;
|
|
|
|
public abstract class DependencyGroup
|
|
{
|
|
public abstract void InvokeInjection(Delegate injection);
|
|
}
|
|
|
|
public class DependencyGroup<TValue> : DependencyGroup
|
|
{
|
|
public required ImmutableList<TValue> Items { get; init; }
|
|
|
|
public override void InvokeInjection(Delegate injection)
|
|
{
|
|
if (injection is Action<ImmutableList<TValue>> action) action(Items);
|
|
else if (injection is Func<ImmutableList<TValue>, Task> awaitableAction) awaitableAction(Items).Wait();
|
|
else throw new InvalidCastException($"Injection point signature mismatch, must be: void/Task (ImmutableList<{typeof(TValue).Name}>)");
|
|
}
|
|
}
|
|
|
|
public class DependencyGroup<TValue, TArguments> : DependencyGroup
|
|
{
|
|
public required ImmutableList<(TValue value, TArguments args)> Items { get; init; }
|
|
|
|
public override void InvokeInjection(Delegate injection)
|
|
{
|
|
if (injection is Action<ImmutableList<(TValue, TArguments)>> action) action(Items);
|
|
else if (injection is Func<ImmutableList<(TValue, TArguments)>, Task> awaitableAction) awaitableAction(Items).Wait();
|
|
else throw new InvalidCastException($"Injection point signature mismatch, must be: void/Task (ImmutableList<({typeof(TValue).Name}, {typeof(TArguments).Name})>)");
|
|
}
|
|
}
|