public void Run() { var composites = settings.Assemblies.SelectMany(assembly => { return(assembly.GetTypes() .Select(type => new { Type = type, Attributes = type.GetCustomAttributesArray <CompositeAttribute>() }) .Where(composite => composite.Attributes.Length > 0)); }); var bulkWeaving = new BulkWeaving(composites.Select(composite => { CompositeTypeWeaverBuilder builder = null; if (composite.Attributes.Length > 1) { throw new DuplicateCompositeAnnotationException(composite.Type); } builder = new CompositeTypeWeaverBuilder(composite.Type, registry); return(builder.Build()); })); bulkWeaving.Weave(); }
public void Run() { ITypeWeaver bulkWeaving = null; var compositesQueue = new Queue <ITypeWeaver>(); AspectsAttributeWeaver aspectRepository = null; AspectArgsMapperWeaver aspectArgsMapperWeaver = null; var aspectDefinitionsTypeSet = new HashSet <Type>(); var composites = typeFactory.Types.Select(type => new { Type = type, Attributes = type.GetCustomAttributesArray <CompositeAttribute>() }) .Where(composite => composite.Attributes.Length > 0); var compositeWeavingSettings = composites.ToList(composite => { var compositeType = composite.Type; var mixinsMap = new MixinsMap(compositeType); var aspectMappedMembers = new AspectMemberMapper(compositeType, mixinsMap); var aspectsMap = new AspectsMap(aspectMappedMembers); var aspectDefinitionsTypes = aspectsMap.SelectMany(aspectMap => { return(aspectMap.Aspects.Select(aspectDefinition => { return aspectDefinition.Aspect.AspectType; })); }); aspectDefinitionsTypeSet.AddRange(aspectDefinitionsTypes); return(new CompositeWeavingSettingsImpl { Registry = registry, MixinsMap = mixinsMap, AspectsMap = aspectsMap, CompositeType = compositeType, AspectMemebrsCollection = aspectMappedMembers }); }); aspectArgsMapperWeaver = new AspectArgsMapperWeaver(); aspectRepository = new AspectsAttributeWeaver(aspectDefinitionsTypeSet); compositesQueue.Enqueue(aspectArgsMapperWeaver); compositesQueue.Enqueue(aspectRepository); compositeWeavingSettings.ForEach(compositeSettings => { IBuilder <ITypeWeaver> builder = null; compositeSettings.AspectRepository = aspectRepository; compositeSettings.AspectArgsMapper = aspectArgsMapperWeaver; builder = new CompositeTypeWeaverBuilder(compositeSettings); compositesQueue.Enqueue(builder.Build()); }); bulkWeaving = new BulkWeaving(compositesQueue); bulkWeaving.Weave(); }