-
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
437c20a
commit d3fa5f5
Showing
20 changed files
with
354 additions
and
100 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
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
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
12 changes: 12 additions & 0 deletions
12
src/AutoAopProxyGenerator/Attributes/GenAspectProxyAttribute.cs
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace AutoAopProxyGenerator; | ||
|
||
/// <summary> | ||
/// 标记需要生成代理类的类型 | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public sealed class GenAspectProxyAttribute : Attribute | ||
{ | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/AutoAopProxyGenerator/Attributes/IgnoreAspectAttribute.cs
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace AutoAopProxyGenerator; | ||
|
||
/// <summary> | ||
/// 配置不需要切面的方法 | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method)] | ||
public sealed class IgnoreAspectAttribute : Attribute | ||
{ | ||
|
||
} |
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Linq; | ||
|
||
namespace AutoAopProxyGenerator; | ||
|
||
public static class ContextHelper<TService, TImpl> | ||
{ | ||
private static readonly ConcurrentDictionary<string, ProxyContext> caches = []; | ||
private static readonly Type ServiceType = typeof(TService); | ||
private static readonly Type ImplType = typeof(TImpl); | ||
public static ProxyContext GetOrCreate(string methodName, Type[] types) | ||
{ | ||
var key = $"{ServiceType.FullName}_{ImplType.FullName}_{methodName}_{string.Join("_", types.Select(t => t.Name))}"; | ||
return caches.GetOrAdd(key, (k) => | ||
{ | ||
var serviceMethod = ServiceType.GetMethod(methodName, types); | ||
var implMethod = ImplType.GetMethod(methodName, types); | ||
return new ProxyContext() | ||
{ | ||
ServiceType = ServiceType, | ||
ImplementType = ImplType, | ||
ServiceMethod = serviceMethod, | ||
ImplementMethod = implMethod | ||
}; | ||
}); | ||
|
||
} | ||
} | ||
|
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
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,7 @@ | ||
`AutoInjectAttribute` | ||
`AddAspectHandlerAttribute` | ||
|
||
`AutoInjectContextAttribute` | ||
`GenAspectProxyAttribute` | ||
|
||
`AutoInjectConfiguration` | ||
`IgnoreAspectAttribute` | ||
|
||
`IAspectHandler` |
Oops, something went wrong.