antyadev / kingaop Goto Github PK
View Code? Open in Web Editor NEW.NET AOP framework - a free alternative of PostSharp.
License: MIT License
.NET AOP framework - a free alternative of PostSharp.
License: MIT License
Why are we inheriting from : IDynamicMetaObjectProvider and the object should be type of dynamic. Is it not possible to make it work without changing the object to dynamic type and inheriting from the above Interface ?
Just downloaded the code and ran the test and one test fails (OnEntry_ShouldNotChange_StringArgument_PassedAsRef())
PostSharp
https://doc.postsharp.net/m_postsharp_aspects_methodinterceptionargs_proceed
Proceeds with invocation of the method that has been intercepted by calling the next node in the chain of invocation.....
Castle.Core
IInvocation.Proceed
Proceeds the call to the next interceptor in line, and ultimately to the target method.
KingAOP
Each MethodInterceptionAspect has OnInvoke invoked regardless of MethodInterceptionArgs.Proceed.
If n MethodInterceptionAspect invoke Proceed then the statically bound method is invoked n times.
I want to use it for implemented WCF services not contracts,
I have tested it as it sample for a WCF service but nothing happened?
It would appear that to invoke logging for a method even if its decorated with a logging aspect attribute has to be called externally via the instance of the dynamic object reference.
static method never gets logged.
like postsharp,when compile project,the postsharp will notify : " attribute with ApplyToStateMachine "
I'm trying to intercept the method calls to a ironpython exposed c# object.For whatever reason this doesn't quite work. I'm trying to find out why but so far no success. Maybe there is some apparent reason why this is the case?
pls add standard aspects like attribute based authorisation:
example:
class hello {
[Role("Admin")]
public string l {get;set;}
}
I am using KingAOP for caching purpose. so I am creating a CustomAttribue class and override the OnEntry and OnSucess method.
I am sharing codes we have used in our application. Can you please suggest me how can invoke these methods.
[Serializable]
[AttributeUsage(AttributeTargets.Method)]
public class CacheAttribute : OnMethodBoundaryAspect
{
// This field will be set by CompileTimeInitialize and serialized at build time, then deserialized at runtime.
private string cacheKey;
private List dependentTableNames;
private static readonly ConcurrentDictionary<string, object> wosDataCache = new ConcurrentDictionary<string, object>();
public CacheAttribute(WOSDbTable dependentTableName, params WOSDbTable[] dependentTableNames)
{
this.dependentTableNames = new List<WOSDbTable>();
this.dependentTableNames.Add(dependentTableName);
this.dependentTableNames.AddRange(dependentTableNames.Select(tableName => tableName));
}
public override void OnEntry(MethodExecutionArgs args)
{
object readValue;
wosDataCache.TryGetValue(cacheKey, out readValue);
if (readValue != null)
{
args.ReturnValue = readValue;
args.FlowBehavior = FlowBehavior.Return;
}
}
public override void OnSuccess(MethodExecutionArgs args)
{
if (new DBConnectionCore().RegisterSqlDependency(SqlDependencyChanged, dependentTableNames).Result)
{
wosDataCache.TryAdd(cacheKey, args.ReturnValue);
}
}
}
public class StaticDataContext : IStaticDataContext, IDynamicMetaObjectProvider where T : IStaticDataModel
{
[Cache(WOSDbTable.LanguageMaster, WOSDbTable.TranslationKeyMaster, WOSDbTable.TranslationMaster)]
public async Task<List> GetStaticDataAsync()
{
DBConnectionCore dbConnectionCore = new DBConnectionCore();
using (IDataReader dataReader = await dbConnectionCore.ExecuteReaderAsync(WOSDbStoredProc.USP_GetStaticData).ConfigureAwait(false))
{
return await dataReader.ToFlatModelAsync().ConfigureAwait(false);
}
}
public DynamicMetaObject GetMetaObject(Expression parameter)
{
return new AspectWeaver(parameter, this);
}
}
When creating two attributes it generates an "An entry with the same key already exists."
Ex: I have a method that add user and for this method I created two attributes one that authorization and another that time of excution both work but when set together it generates the error: "An entry with the same key already exists."
It would appear that to invoke logging for a method even if its decorated with a logging aspect attribute has to be called externally via the instance of the dynamic object reference. This would be a huge limitation as it appears that internal method call that take place within the class itself never get their respective aspect invoked and thus never get logged as part of a call start. Or whatever other functionality you might introduce other than logging. This would mean that in order to use this framework one would have to change their architecture so that every single method gets called in reference to the dynamic instance of an object and can not call methods internally if they are expecting aspect based behavior to execute.
could you please?
Hi, I used LogginAspect attribute on web service method call. The first call of the web service for each method logged true. But other calls logged with the first call args. Args not changed between calls like static variable. So LoggingAspect not work on asp.net webservice truely.
When i called the same method twice,it still use the first time arguments,how to fix it ?
I use kingAOP in mvvm light , I have no idea to integrate with ioc. Please give me some advice.
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.