static bool GetMethodInfo(MethodInfo method, Type attribute) {
     if (method.IsAbstract || method.ContainsGenericParameters || method.IsConstructor || method.IsGenericMethod || method.IsStatic)
         return false;
     var attributes = method.GetCustomAttributesData();
     var info = attributes.FirstOrDefault(x => x.AttributeType == attribute);
     return info != null;
 }
        static private void AppendMethodInfo(MethodInfo method, StringBuilder sb)
        {
            sb.Append(".method");

            foreach (var attribute in method.GetCustomAttributesData())
            {
                sb.Append(" ");
                AppendCustomAttributeData(attribute, sb);
            }

            sb.Append(" ");
            AppendMethodAttributes(sb, method.Attributes);
            sb.Append(" ");
            AppendParameterInfo(method.ReturnParameter, sb);
            sb.Append(" ");
            sb.Append(method.Name);

            if (method.IsGenericMethod)
            {
                sb.Append("<");
                foreach (var typeParameter in method.GetGenericArguments())
                {
                    AppendType(typeParameter, sb, true);
                    AppendComma(sb);
                }
                RemoveTrailingComma(sb);
                sb.Append(">");
            }

            sb.Append("(");
            foreach (var parameter in method.GetParameters())
            {
                AppendParameterInfo(parameter, sb);
                AppendComma(sb);
            }
            RemoveTrailingComma(sb);
            sb.Append(") ");
            AppendMethodImplAttributes(sb, method.GetMethodImplementationFlags());
        }
        IEnumerable<RoleAttribute> FindRoleAttributes(MethodInfo method)
        {
            var result = (IEnumerable<RoleAttribute>) Attribute.GetCustomAttributes(method, typeof(RoleAttribute));

            foreach (var data in method.GetCustomAttributesData()) {
                if (data.Constructor.DeclaringType.Assembly.Equals(typeof(ReflectedPropertyTreeDefinition).Assembly)) {
                    continue;
                }

                if (data.Constructor.DeclaringType.FullName == typeof(AddAttribute).FullName) {
                    return new [] { AddAttribute.Default };
                }
            }
            return result;
        }
 public void EnrichMethod(IProcessingContext context, MethodInfo mInfo)
 {
     GenerateAttributeElements(context, mInfo.GetCustomAttributesData());
 }
        private static String GetRouteAttribute(MethodInfo method, String route)
        {
            var actionRoute =
                method.GetCustomAttributesData()
                    .FirstOrDefault(z => z.AttributeType == typeof(RouteAttribute));

            if (actionRoute == null)
                return IncorrectRoute;

            return actionRoute.ConstructorArguments.Count == 0
                ? route
                : String.Format("{0}{1}/", route, actionRoute.ConstructorArguments.First().Value);
        }