You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
750 B
29 lines
750 B
using ReZero.DependencyInjection; |
|
using ReZero.SuperAPI; |
|
namespace SuperAPITest.Controllers |
|
{ |
|
/// <summary> |
|
/// 动态接口+IOC |
|
/// </summary> |
|
[Api(200100,GroupName = "分组2")] |
|
public class MyApiWithIocController |
|
{ |
|
//属性注入 |
|
[DI] |
|
public MyService? MyService { get; set; } |
|
|
|
[ApiMethod("我是A方法")] |
|
public int A(int num, int num2) |
|
{ |
|
return this.MyService!.CalculateSum(num, num2); |
|
} |
|
} |
|
//继承IScopeContract 、ISingletonContract或者ITransientContract就可以自动注入 |
|
public class MyService : IScopeContract |
|
{ |
|
public int CalculateSum(int num, int num2) |
|
{ |
|
return num2 + num; |
|
} |
|
} |
|
}
|
|
|