public IAspectLifecycle GetLifecycle(Type aspectType, IAspectFactory factory) { return(PerCFlowAspectLifecycle.For(aspectType)); }
public IAspectLifecycle GetLifecycle(Type aspectType, IAspectFactory factory) { return(new SingletonAspectLifecycle(aspectType, factory)); }
public SingletonAspectLifecycle(Type type, IAspectFactory factory) { _factory = factory; _type = type; }
/// <summary> /// Create with aspect factory. /// </summary> /// <param name="factory"></param> protected WithAspect(IAspectFactory <TInput, TOutput> factory) : this(factory.GeneralAspect, factory.Before, factory.After) { }
public IAspectLifecycle GetLifecycle(Type aspectType, IAspectFactory factory) { return(new PerThisAspectLifecycle(aspectType, string.IsNullOrEmpty(ActivateOnPointcut))); }
public void SetFactory <TAspect>(IAspectFactory factory) { factories[typeof(TAspect)] = factory; }
/// <inheritdoc /> public IInvocationWeaveDataProvider Create(Type declaredType, Type targetType) { var key = new TypePair(declaredType, targetType); return(_providerCache.GetOrAdd(key, typeKey => { var invocationsData = new ConcurrentDictionary <IInvocationSignature, InvocationWeaveData>( InvocationSignature.InvocationSignatureMethodEqualityComparer.Instance); var declaredMethods = typeKey.DeclaringType.GetMethods() .Union(typeKey.DeclaringType.GetInterfaces() .SelectMany(i => i.GetMethods())); foreach (var declaredMethod in declaredMethods) { var targetMethod = ReflectedMethod.GetMethodMap(typeKey.ImplementationType, declaredMethod); if (targetMethod == null) { throw new IvorySharpException( $"Не удалось найти метод '{declaredMethod.Name}' в типе '{typeKey.ImplementationType.Name}'"); } var signature = new InvocationSignature( declaredMethod, targetMethod, typeKey.DeclaringType, typeKey.ImplementationType, declaredMethod.GetInvocationType()); if (_weavePredicate == null) { _weavePredicate = _weavePredicateHolder.Get(); } var isWeaveable = _weavePredicate.IsWeaveable(signature); if (!isWeaveable) { invocationsData.TryAdd(signature, InvocationWeaveData.Unweavable()); continue; } if (_factory == null) { _factory = _preInitializerHolder.Get(); } var boundaryAspects = _factory.CreateBoundaryAspects(signature); var interceptAspect = _factory.CreateInterceptAspect(signature); if (_pipelineFactory == null) { _pipelineFactory = _pipelineFactoryHolder.Get(); } var pipeline = _pipelineFactory.CreatePipeline(signature, boundaryAspects, interceptAspect); var executor = _pipelineFactory.CreateExecutor(signature); invocationsData.TryAdd(signature, InvocationWeaveData.Weavable(pipeline, executor, boundaryAspects, interceptAspect)); } return new InvocationWeaveDataProvider(invocationsData); })); }
public AspectInterceptor(IAspectFactory aspectFactory) { if (aspectFactory == null) throw new ArgumentNullException("aspectFactory"); this.aspectFactory = aspectFactory; }
public IAspectLifecycle GetLifecycle(Type aspectType, IAspectFactory factory) { return(new TransientAspectLifecycle(jp => factory.CreateInstance(aspectType, jp))); }