Exemple #1
0
 /// <summary>
 /// Gets the marked methods.
 /// </summary>
 /// <param name="reflectionNode">The reflection node.</param>
 /// <param name="markerInterface">The marker interface.</param>
 /// <param name="types">The types.</param>
 /// <returns></returns>
 private IEnumerable <MarkedNode> GetMarkedMethods(ReflectionNode reflectionNode, TypeDefinition markerInterface, Types types)
 {
     return(reflectionNode.GetAncestorsToChildren().AsParallel()
            .Where(n => n.Method != null)
            .Select(n => new MarkedNode {
         Node = n, Definitions = GetAllMarkers(n, markerInterface, types).ToArray()
     })
            .Where(m => m.Definitions.Length > 0));
 }
Exemple #2
0
        /// <summary>
        /// Gets all attributes that implement the given advice interface
        /// </summary>
        /// <param name="reflectionNode">The reflection node.</param>
        /// <param name="markerInterface">The advice interface.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        private IEnumerable <MarkerDefinition> GetAllMarkers(ReflectionNode reflectionNode, ITypeDefOrRef markerInterface, WeavingContext context)
        {
            var markers = reflectionNode.GetAncestorsToChildren()
                          .SelectMany(n => n.CustomAttributes
                                      .Where(a => !a.AttributeType.DefinitionAssembly.IsSystem())
                                      .SelectMany(a => TypeResolver.Resolve(a.AttributeType).GetSelfAndParents())
                                      .Where(t => IsMarker(t, markerInterface)))
                          .Distinct()
                          .Select(t => GetMarkerDefinition(t, context));

            return(markers);
        }
Exemple #3
0
        /// <summary>
        /// Gets the marked methods.
        /// </summary>
        /// <param name="reflectionNode">The reflection node.</param>
        /// <param name="markerInterface">The marker interface.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        private IEnumerable <MarkedNode> GetMarkedMethods(ReflectionNode reflectionNode, ITypeDefOrRef markerInterface, WeavingContext context)
        {
            var ancestorsToChildren = reflectionNode.GetAncestorsToChildren().ToArray();

            return(from node in ancestorsToChildren
                   where node.Method != null
                   let allMakersNode = new MarkedNode(node, GetAllMarkers(node, markerInterface, context))
                                       where allMakersNode.Definitions.Any() && IsIncludedByPointcut(allMakersNode, context)
                                       let includedMarkersNode = new MarkedNode(node, allMakersNode.Definitions.Where(d => IsIncludedByNode(d, node, context)))
                                                                 where includedMarkersNode.Definitions.Any()
                                                                 select includedMarkersNode);
        }
Exemple #4
0
        /// <summary>
        /// Gets all attributes that implement the given advice interface
        /// </summary>
        /// <param name="reflectionNode">The reflection node.</param>
        /// <param name="markerInterface">The advice interface.</param>
        /// <param name="types">The types.</param>
        /// <returns></returns>
        private IEnumerable <MarkerDefinition> GetAllMarkers(ReflectionNode reflectionNode, TypeDefinition markerInterface, Types types)
        {
            var markers = reflectionNode.GetAncestorsToChildren()
                          .SelectMany(n => n.CustomAttributes.SelectMany(a => a.AttributeType.Resolve().GetSelfAndParents())
                                      .Where(t => IsMarker(t, markerInterface)))
                          .Distinct()
                          .Select(t => GetMarkerDefinition(t, types));

#if DEBUG
            //            Logger.WriteDebug(string.Format("{0} --> {1}", reflectionNode.ToString(), markers.Count()));
#endif
            return(markers);
        }
Exemple #5
0
 /// <summary>
 /// Gets the marked methods.
 /// </summary>
 /// <param name="reflectionNode">The reflection node.</param>
 /// <param name="markerInterface">The marker interface.</param>
 /// <returns></returns>
 private IEnumerable<MethodDefinition> GetMarkedMethods(ReflectionNode reflectionNode, TypeDefinition markerInterface)
 {
     return reflectionNode.GetAncestorsToChildren().AsParallel()
         .Where(n => n.Method != null && GetAllMarkers(n, markerInterface).Any())
         .Select(n => n.Method);
 }
Exemple #6
0
 /// <summary>
 /// Gets all attributes that implement the given advice interface
 /// </summary>
 /// <param name="reflectionNode">The reflection node.</param>
 /// <param name="markerInterface">The advice interface.</param>
 /// <returns></returns>
 private IEnumerable<TypeReference> GetAllMarkers(ReflectionNode reflectionNode, TypeDefinition markerInterface)
 {
     var markers = reflectionNode.GetAncestorsToChildren()
         .SelectMany(n => n.CustomAttributes.SelectMany(a => a.AttributeType.Resolve().GetSelfAndParents()).Where(t => IsMarker(t, markerInterface)))
         .Distinct();
     #if DEBUG
     //            Logger.WriteDebug(string.Format("{0} --> {1}", reflectionNode.ToString(), markers.Count()));
     #endif
     return markers;
 }