Skip to content
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

Multiple Aspect On Method #119

Closed
murseld opened this issue Dec 6, 2019 · 5 comments
Closed

Multiple Aspect On Method #119

murseld opened this issue Dec 6, 2019 · 5 comments
Labels

Comments

@murseld
Copy link

murseld commented Dec 6, 2019

Hello pamidur and me again :)

When I want to use multiple aspect for example CacheAspect and LogAspect,
CacheAspect (if cache contains any data) prevents the other LogAspect from using the Kind.After property because log aspect is logging when method is complete.

How can I avoid this do you have any advice.
Thank you my friend..

[LogAspect(typeof(NLogManager))]
[CacheAspect(typeof(RedisCacheManager), 15)]
public User Get(int? key)
{
return _userDal.Get(p => p.UserId == key);
}

CacheAspect.txt
LogAspect.txt

@pamidur
Copy link
Owner

pamidur commented Dec 9, 2019

Hi @murseld ,
Aspect with Kind.Around effectively override any other kind. But you can use multiple Kind.Around aspects. Don't forget to set Injection.Priority

For these to work you need to implement all of yours concurrent aspects as Kind.Around.

I'll leave this issue opened as I think I could come up with how to make priorities "cross-kind" e.g. make all Before and After as part of another internal Around.

@pamidur
Copy link
Owner

pamidur commented Apr 12, 2020

Hey @murseld , I have recently implemented Cache aspect. Could you please take a look and see if it can suit your needs?
https://github.com/pamidur/aspect-injector/tree/master/samples/src/Cache

I'm asking as you're the one with real cache problem need to solve.
Would be great if you take a look :)

@murseld
Copy link
Author

murseld commented Apr 12, 2020

Hi pamidur
it was great. thank you very much...

@pamidur
Copy link
Owner

pamidur commented Apr 30, 2020

Hi @murseld , I've created new prerelease 2.4.0-beta1. I changed weavers priority in it. So Before/After are always injected even when other aspect with Around is used. You may try it!

@pamidur
Copy link
Owner

pamidur commented Oct 18, 2021

Should be fixed now. Please feel free to reopen

@pamidur pamidur closed this as completed Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants