public void Execute(TypeContextFactory factory) { foreach (var assembly in _assemblies) { List <Type> foundTypes = new List <Type>(); if (_types != null) { foreach (var type in _types) { foundTypes.AddRange(assembly.GetTypes().Where(x => !x.IsAbstract && x.CanBeCastTo(type))); } } else { var badNames = new[] { "System", "Microsoft" }; foundTypes.AddRange(assembly.GetTypes().Where(x => !x.IsAbstract && !x.IsInterface && !badNames.Any(b => x.Name.StartsWith(b)))); } foreach (var foundType in foundTypes) { _action.Invoke(foundType, factory); } } }
public override object Instance(TypeContextFactory factory, IBaseTypeAction typeAction) { lock (_lock) { return(HttpContext.Current.Session[typeAction.InterfaceType.Name] ?? (HttpContext.Current.Session[typeAction.InterfaceType.Name] = base.Instance(factory, typeAction))); } }
private void ProcessAspectDefinitions(MethodDefinition targetMethod, string targetName, IEnumerable <AspectDefinition> aspectDefinitions) { var filteredDefinitions = aspectDefinitions.Where(def => CheckFilter(targetMethod, targetName, def)); var mergedDefinitions = MergeAspectDefinitions(filteredDefinitions); var contexts = mergedDefinitions .Select(def => { var adviceClassType = def.AdviceClassType; var aspectScope = targetMethod.IsStatic ? AspectScope.Type : AspectScope.Instance; if (adviceClassType.CustomAttributes.HasAttributeOfType <AspectScopeAttribute>()) { aspectScope = (AspectScope)adviceClassType.CustomAttributes.GetAttributeOfType <AspectScopeAttribute>().ConstructorArguments[0].Value; } var aspectContext = new AspectContext() { TargetName = targetName, TargetTypeContext = TypeContextFactory.GetOrCreateContext(targetMethod.DeclaringType), AdviceClassType = adviceClassType, AdviceClassScope = aspectScope, AspectRoutableData = def.RoutableData == null ? new CustomAttribute[] { } : def.RoutableData.ToArray() }; return(aspectContext); }) .Where(ctx => _processors.Any(p => p.CanProcess(ctx.AdviceClassType))) .ToList(); Validator.ValidateAspectContexts(contexts); foreach (var context in contexts) { var targetMethodContext = MethodContextFactory.GetOrCreateContext(targetMethod); context.TargetMethodContext = targetMethodContext; //setting it here for better performance foreach (var processor in _processors) { if (processor.CanProcess(context.AdviceClassType)) { processor.Process(context); } } } }
public void Execute(TypeContextFactory factory) { factory.Add(new TypeAction <UsedForScannerOnly, UsedForScannerOnly>()); }
public object Instance(TypeContextFactory factory) { return(RegisteredTypeAction.LifeSpan.Instance(factory, RegisteredTypeAction)); }
public TypeContext() { _factory = new TypeContextFactory(); _factory.Add(new TypeAction <ITypeContext, TypeContext>(this)); }