Example #1
0
        public AspectWeaver <T> WeaveAspects(
            AbstractAspectProvider aspectProvider,
            params IEnumerable <MemberProjection>[] pointCuts)
        {
            if (_factoryReady)
            {
                throw new InvalidOperationException(
                          "Cannot change an aspect weaver once it provides a factory. Bad stuff would happen.");
            }

            var namedGroups = from v in pointCuts.SelectMany(x => x)
                              group v by v.Name
                              into nameGroup
                              select new
            {
                Name      = nameGroup.Key,
                PointCuts = nameGroup
            };

            foreach (var ng in namedGroups)
            {
                if (!_mappings.ContainsKey(ng.Name))
                {
                    _mappings.Add(ng.Name, new Dictionary <MemberProjection, HashSet <AbstractAspectProvider> >());
                }

                var lookupTable = _mappings[ng.Name];

                foreach (var pc in ng.PointCuts)
                {
                    if (!lookupTable.ContainsKey(pc))
                    {
                        lookupTable.Add(pc, new HashSet <AbstractAspectProvider>());
                    }

                    lookupTable[pc].Add(aspectProvider);
                }
            }

            return(this);
        }
Example #2
0
 public AspectWeaver <T> WeaveAspects(
     AbstractAspectProvider aspectProvider,
     params Func <FromClass <T>, IEnumerable <MemberProjection> >[] pointCutsDelegates)
 {
     return(WeaveAspects(aspectProvider, pointCutsDelegates.SelectMany(pcd => pcd((new FromClass <T>())))));
 }