-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a53f795
commit 6b7bd62
Showing
2 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,41 @@ | ||
`AddAspectHandlerAttribute` | ||
# AutoAopProxyGenerator | ||
|
||
`GenAspectProxyAttribute` | ||
## 介绍 | ||
|
||
`IgnoreAspectAttribute` | ||
本项目是一个增量生成器,用于生成AOP代理类 | ||
|
||
`IAspectHandler` | ||
> https://www.cnblogs.com/marvelTitile/p/18382803 | ||
## 使用 | ||
|
||
1. 在接口或者方法中添加`AddAspectHandlerAttribute`,并指定`AspectType`,可重复添加不同的`AspectType` | ||
2. 在实现类中添加`GenAspectProxyAttribute`,指示生成器为该类型生成代理类,生成的代理类名为`{实现类}GeneratedProxy` | ||
3. 在容器中配置`AutoAopProxyServiceProviderFactory`,目前仅支持官方的IOC容器 | ||
```chsarp | ||
builder.Host.UseServiceProviderFactory(new AutoAopProxyServiceProviderFactory()); | ||
``` | ||
|
||
## 相关特性介绍 | ||
|
||
### AddAspectHandlerAttribute | ||
|
||
标注接口/方法,添加AOP处理程序 | ||
|
||
#### 属性 | ||
|
||
| 名称 | 类型 | 说明 | | ||
| -------------- | -------- | ---------------------- | | ||
| AspectType | Type | 切面处理类型 | | ||
| SelfOnly | bool | 是否只适用于当前类型的方法,当设置为true时,不适用于继承而来的方法,默认为false | | ||
|
||
### GenAspectProxyAttribute | ||
|
||
标注类型,指示生成器为该类型生成代理类 | ||
|
||
### IgnoreAspectAttribute | ||
|
||
标注方法,忽略AOP处理 | ||
|
||
#### 构造函数参数 `params Type[] ignoreTypes` | ||
|
||
指定忽略的类型,默认忽略全部 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,50 @@ | ||
`AutoInjectAttribute` | ||
# AutoInjectGenerator | ||
|
||
`AutoInjectContextAttribute` | ||
## 介绍 | ||
|
||
`AutoInjectConfiguration` | ||
本项目是一个增量生成器,用于生成自动注入方法 | ||
|
||
> https://www.cnblogs.com/marvelTitile/p/18382803 | ||
## 使用 | ||
|
||
1. 实现类添加`AutoInjectAttribute` | ||
2. 新建一个静态分部类,添加`AutoInjectContextAttribute`,并提供一个静态分部方法 | ||
```csharp | ||
[AutoInjectContext] | ||
public static partial class AutoInjectContext | ||
{ | ||
public static partial void YourMethodName(this IServiceCollection services); | ||
} | ||
``` | ||
3. 调用方法 | ||
```csharp | ||
services.YourMethodName(); | ||
``` | ||
|
||
## 相关特性介绍 | ||
|
||
### AutoInjectAttribute | ||
|
||
标注实现类,生成服务注入代码 | ||
|
||
#### 属性 | ||
|
||
| 名称 | 类型 | 说明 | | ||
| -------------- | -------- | ---------------------- | | ||
| LifeTime | [InjectLifeTime] | 注入周期 | | ||
| ServiceType | Type | 服务类型,默认为类的第一个接口/自身 | | ||
|Group|string|分组,默认为空| | ||
|ServiceKey|object|服务键,默认为null| | ||
|IsTry|bool|是否使用TryAdd,默认为false| | ||
|
||
### InjectLifeTime | ||
|
||
可能的值 | ||
+ Transient | ||
+ Scoped(默认值) | ||
+ Singleton | ||
|
||
### AutoInjectContextAttribute | ||
|
||
指示生成调用方法 |