Exemple #1
0
        public static void AcceptVisitor <TResult> (
            this MethodDefinition methodDefinition,
            MetadataVisitor <TResult> visitor)
        {
            if (!visitor.ShouldTraverseInto(visitor.VisitMethodDefinition(methodDefinition)))
            {
                return;
            }

            if (methodDefinition.HasCustomAttributes)
            {
                methodDefinition.CustomAttributes.AcceptVisitor(visitor);
            }

            if (methodDefinition.HasGenericParameters)
            {
                methodDefinition.GenericParameters.AcceptVisitor(visitor);
            }

            if (methodDefinition.HasParameters)
            {
                foreach (var parameter in methodDefinition.Parameters)
                {
                    parameter.AcceptVisitor(visitor);
                }
            }

            methodDefinition.ReturnType.AcceptVisitor(visitor);

            if (methodDefinition.HasBody)
            {
                methodDefinition.Body.AcceptVisitor(visitor);
            }
        }