-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
兄弟,文档不更新都是坑啊 #262
Comments
.net 5 项目表示都不知道怎么替换默认依赖注入了 |
例子都还是.net core 2的,我更新到.net 5 |
我發現屬性或是方法都沒有寫註解.... 有人知道是為甚麼嗎? |
确实,看文档看了一小时,下载Nuget包准备用的时候,满满的挫败感 |
你的具体问题是啥呢 |
不好意思,今天才回复。在asp.net中确实尝试成功了 Program.cs using AspectCore.Extensions.DependencyInjection;
using AspectDemo.WebApplication1.Services;
using Microsoft.AspNetCore.Mvc;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTransient<IDemoService, DemoService>();
builder.Services.ConfigureDynamicProxy();
builder.Host.UseServiceProviderFactory(new DynamicProxyServiceProviderFactory());
var app = builder.Build();
app.UseRouting();
app.MapGet("/", () => "hi");
app.MapGet("/id", ([FromServices]IDemoService service) => service.GeneratorId());
app.Run(); IDemoService.cs public interface IDemoService
{
[Log]
string GeneratorId();
}
public class LogAttribute : AbstractInterceptorAttribute
{
public override async Task Invoke(AspectContext context, AspectDelegate next)
{
var watch = Stopwatch.StartNew();
await next(context);
watch.Stop();
Console.WriteLine($"{context.ProxyMethod.Name} invoke time-consuming:{watch.Elapsed}ms");
}
} 但是在控制台程序或WPF、WinForm上,AOP相关代码一直不执行,示例太少,也不知道哪里没配置好 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
新版本的方法,使用都改了,文档没跟,使用者踩着坑,浪费时间啊!
var container = services.ToServiceContainer();
return container.Build();
看例子的这些都没法用........
The text was updated successfully, but these errors were encountered: