public object Intercept(IJointPoint jp) { var interception = new InterceptionImpl(); try { Before(interception); if (!interception.IsPrevented) { interception.ReturnValue = jp.Execute(); } Success(jp, interception.Reset(), interception.ReturnValue); } catch (Exception e) { Error(jp, interception.Reset(), e); if (!interception.IsPrevented) { throw; } } finally { Exit(jp, interception.Reset(), interception.ReturnValue); } return(interception.ReturnValue); }
public object GetAspect(IJointPoint jointPoint) { if (jointPoint.This == null) { return(null); } return(_aspectByTypes.GetOrPut(jointPoint.This.GetType(), () => _factory(jointPoint))); }
public object CreateInstance(Type type, IJointPoint joinpoint) { var obj = Instantiate(type); if (obj is IAspectAware aspectAware) { aspectAware.OnCreated(joinpoint); } return(obj); }
public object WrapFlowScope(IJointPoint joinpoint) { var aspectType = typeof(TAspectType); var lifecycle = PerCFlowAspectLifecycle.For(aspectType); lifecycle.Push(AspectRuntime.Provider.GetFactory(aspectType).CreateInstance(aspectType, joinpoint)); try { return(joinpoint.Execute()); } finally { lifecycle.Pop(); } }
public object GetAspect(IJointPoint jointPoint) { if (!_isCreated) { lock (this) { if (!_isCreated) { _instance = _factory.CreateInstance(_type, jointPoint); _isCreated = true; } } } return(_instance); }
public object GetAspect(IJointPoint jointPoint) { if (jointPoint.This == null) { return(null); } var aspect = ObjectBoundAspects.GetOrCreateValue(jointPoint.This).Get(_type); if (aspect == null && _autoInstantiate) { Bind(jointPoint, _type); aspect = ObjectBoundAspects.GetOrCreateValue(jointPoint.This).Get(_type); } return(aspect); }
public object CreateInstance(Type type, IJointPoint joinpoint) { MemberInfo member = null; if (joinpoint is ICallJointPoint callJp) { member = callJp.TargetMember; } if (joinpoint is IMemberJointPoint memberJp) { member = memberJp.Member; } return(member == null ? null : member.GetCustomAttributesData() .Where(a => type.IsAssignableFrom(a.Constructor.ReflectedType)) .Select(ReflectionHelper.CreateAttribute) .FirstOrDefault()); }
public object Bind(IJointPoint jp) { PerThisAspectLifecycle.Bind(jp, typeof(TAspect)); return(jp.Execute()); }
public object GetAspect(IJointPoint jointPoint) { return(_factory(jointPoint)); }
public static TAspect GetAspect <TAspect>(IJointPoint jointpoint) { return((TAspect)Provider.GetLifecycle(typeof(TAspect)).GetAspect(jointpoint)); }
protected void Exit(IJointPoint jp, IInterception reset, object returnValue) { }
protected void Error(IJointPoint jp, IInterception reset, Exception exception) { }
protected void Success(IJointPoint jp, IInterception context, object returnValue) { }
public object Around(IJointPoint pointcut) { return(_uniqueId); }
public void StealNonTransactionalMethods(IJointPoint jp) { _nonTransactionalActions.Enqueue(() => jp.Execute()); }
public object CreateInstance(Type type, IJointPoint joinpoint) { return(_container.GetInstance(type)); }
public static void Bind(IJointPoint jp, Type aspectType) { ObjectBoundAspects.GetOrCreateValue(jp.This).Bind(aspectType, () => AspectRuntime.Provider.GetFactory(aspectType).CreateInstance(aspectType, jp)); }
public object GetAspect(IJointPoint jointPoint) { var a = _threadStack.Value.Count == 0 ? null : _threadStack.Value.Peek(); return(a); }