Пример #1
0
        private ReflectedMethodInfo BuildMethodInfo(ReflectedTypeInfo typeInfo, MethodInfo method)
        {
            var isNewSlot    = ((method.Attributes & MethodAttributes.NewSlot) == MethodAttributes.NewSlot);
            var isReusedSlot = ((method.Attributes & MethodAttributes.ReuseSlot) == MethodAttributes.ReuseSlot);
            var isOverride   = method.IsVirtual && !isNewSlot && isReusedSlot;
            var methodInfo   = new ReflectedMethodInfo()
            {
                Name              = method.Name,
                Type              = typeInfo,
                DeclaringType     = GetType(method.DeclaringType),
                IsOverride        = isOverride,
                MemberAccess      = DetermineAccess(method),
                IsVirtual         = method.IsVirtual && !isOverride,
                IsStatic          = method.IsStatic,
                IsExtensionMethod = method.GetCustomAttributes(typeof(ExtensionAttribute), false).Any()
            };
            var parameterBuilder = new ParameterBuilder(methodInfo, GetType);

            if (method.IsGenericMethod)
            {
                var genericArgs = method.GetGenericArguments();
                methodInfo.IsGenericMethod   = true;
                methodInfo.GenericParameters = GetGenericParameters(genericArgs, true);
                for (int i = 0; i < genericArgs.Length; i++)
                {
                    foreach (var constraintType in genericArgs[i].GetGenericParameterConstraints())
                    {
                        if (constraintType == typeof(ValueType))
                        {
                            continue;
                        }
                        methodInfo.GenericParameters[i].Types.Add(parameterBuilder.BuildType(constraintType));
                    }
                }
            }
            methodInfo.ReturnType = parameterBuilder.BuildType(method.ReturnType);
            methodInfo.Parameters = GetParameters(method.GetParameters(), parameterBuilder);
            if (methodInfo.IsExtensionMethod)
            {
                methodInfo.Parameters[0].IsExtensionParameter = true;
            }
            return(methodInfo);
        }
Пример #2
0
 private ReflectedMethodInfo BuildMethodInfo(ReflectedTypeInfo typeInfo, MethodInfo method) {
     var isNewSlot = ((method.Attributes & MethodAttributes.NewSlot) == MethodAttributes.NewSlot);
     var isReusedSlot = ((method.Attributes & MethodAttributes.ReuseSlot) == MethodAttributes.ReuseSlot);
     var isOverride = method.IsVirtual && !isNewSlot && isReusedSlot;
     var methodInfo = new ReflectedMethodInfo() {
         Name = method.Name,
         Type = typeInfo,
         DeclaringType = GetType(method.DeclaringType),
         IsOverride = isOverride,
         MemberAccess = DetermineAccess(method),
         IsVirtual = method.IsVirtual && !isOverride,
         IsStatic = method.IsStatic,
         IsExtensionMethod = method.GetCustomAttributes(typeof(ExtensionAttribute), false).Any()
     };
     var parameterBuilder = new ParameterBuilder(methodInfo, GetType);
     if(method.IsGenericMethod) {
         var genericArgs = method.GetGenericArguments();
         methodInfo.IsGenericMethod = true;
         methodInfo.GenericParameters = GetGenericParameters(genericArgs, true);
         for(int i = 0; i < genericArgs.Length; i++) {
             foreach(var constraintType in genericArgs[i].GetGenericParameterConstraints()) {
                 if(constraintType == typeof(ValueType)) {
                     continue;
                 }
                 methodInfo.GenericParameters[i].Types.Add(parameterBuilder.BuildType(constraintType));
             }
         }
     }
     methodInfo.ReturnType = parameterBuilder.BuildType(method.ReturnType);
     methodInfo.Parameters = GetParameters(method.GetParameters(), parameterBuilder);
     if(methodInfo.IsExtensionMethod) {
         methodInfo.Parameters[0].IsExtensionParameter = true;
     }
     return methodInfo;
 }
Пример #3
0
 private void BuildMethodRow(XDoc html, ReflectedMethodInfo member) {
     var xmlDoc = GetDoc(member.Signature);
     html.Start("tr")
             .Elem("td", member.MemberAccess)
             .Start("td").StartSpan("member");
     if(IsTypeInDocumentation(member.DeclaringType)) {
         html.Link(member.UriPath, member.DisplayName);
     } else {
         html.Value(member.DisplayName);
     }
     html
             .EndSpan()
             .StartSpan("description");
     if(member.IsOverride && !member.IsInherited) {
         html.Value("(Override)");
     }
     if(member.IsExtensionMethod) {
         html.Value("(Extension)");
     }
     html.AddNodes(xmlDoc["summary"]);
     if(member.IsInherited) {
         html.Value(string.Format("(Inherited from {0})", member.DeclaringType.DisplayName));
     }
     html
                 .EndSpan()
             .End() // td
         .End(); // tr
 }