yusufyilmazfr / asmin Goto Github PK
View Code? Open in Web Editor NEWAsmin is .NET CORE project infrastructure, to get a quick start on the project.
Asmin is .NET CORE project infrastructure, to get a quick start on the project.
I created new PR: #6
I seperated AOP modules from Asmin.Core to Asmin.Packages.AOP. It provided modular and independent app. It works but we have a problem. IInterceptor does not work when invocation method is async.
We have code in this name space Asmin.Packages.AOP/Interceptor/MethodInterceptorBase.cs
namespace Asmin.Packages.AOP.Interceptor
{
public abstract class MethodInterceptorBase : Attribute, IInterceptor
{
/// <summary>
/// Working priority
/// </summary>
public int Priority { get; set; }
/// <summary>
/// Intercept defined method
/// </summary>
/// <param name="invocation"></param>
public abstract void Intercept(IInvocation invocation);
}
}
namespace Asmin.Packages.AOP.Interceptor
{
/// <summary>
/// MethodInterceptor provides writing aspect.
/// </summary>
public class MethodInterceptor : MethodInterceptorBase
{
/// <summary>
/// OnBefore works before method working
/// </summary>
/// <param name="invocation"></param>
public virtual void OnBefore(IInvocation invocation) { }
/// <summary>
/// OnAfter works last
/// </summary>
/// <param name="invocation"></param>
public virtual void OnAfter(IInvocation invocation) { }
/// <summary>
/// OnSuccess works when method done successfully
/// </summary>
/// <param name="invocation"></param>
public virtual void OnSuccess(IInvocation invocation) { }
/// <summary>
/// OnException works when method throws exception
/// </summary>
/// <param name="invocation"></param>
/// <param name="exception">Throwed exception</param>
public virtual void OnException(IInvocation invocation, Exception exception) { }
/// <summary>
/// Intercept works while method is working
/// </summary>
/// <param name="invocation"></param>
public override void Intercept(IInvocation invocation)
{
bool isSuccess = true;
OnBefore(invocation);
try
{
invocation.Proceed();
}
catch (Exception e)
{
isSuccess = false;
OnException(invocation, e);
}
finally
{
if (isSuccess)
{
OnSuccess(invocation);
}
OnAfter(invocation);
}
}
}
}
I need async operation. I use Castle.Core package for intercepting.
There is documentation for async operation: https://github.com/castleproject/Core/blob/master/docs/dynamicproxy-async-interception.md
I will check it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.