Example #1
0
        internal void AppendCustomAttributes(DescriptionBuilder sb, ICustomAttributeProvider provider)
        {
            const string attributeSuffix = "Attribute";

            Debug.Assert(sb != null && provider != null, "sb != null && provider != null");

            NetBrowserSettings settings = (NetBrowserSettings)Settings;

            foreach (Attribute attr in provider.GetCustomAttributes(false))
            {
                Type attrType = attr.GetType();

                // Remove the "Attribute" suffix from the name.

                string name = attrType.Name;
                if (name.EndsWith(attributeSuffix))
                {
                    name = name.Substring(0, name.Length - attributeSuffix.Length);
                }

                sb.Append(settings.GetKeyword(NetBrowserSettings.KeywordAttributeStart));
                sb.AppendLink(name, GetTypeInfoForLink(
                                  attrType.Assembly.Location, attrType.FullName));
                sb.Append(settings.GetKeyword(NetBrowserSettings.KeywordAttributeEnd));
                sb.EndLine();
            }
        }
Example #2
0
        internal static void WriteParameterType(NetBrowserManager manager, DescriptionBuilder sb,
                                                ParameterInfo parameter, bool link)
        {
            NetBrowserSettings settings = (NetBrowserSettings)manager.Settings;

            if (parameter.IsOut)
            {
                sb.Append(settings.GetKeyword(ParameterAttributes.Out));
                sb.Append(" ");
                AppendParameterTypeDisplayName(manager, sb, parameter.ParameterType, true, link);
            }
            else
            {
                if (parameter.IsDefined(typeof(ParamArrayAttribute), false))
                {
                    sb.Append(settings.GetKeyword(typeof(ParamArrayAttribute)));
                    sb.Append(" ");
                }

                AppendParameterTypeDisplayName(manager, sb, parameter.ParameterType, false, link);
            }
        }
Example #3
0
        internal static string GetOperatorName(NetBrowserSettings settings, string methodName)
        {
            // Replace the method name with the operator declaration, like VS.NET does.

            string opName = settings.GetKeyword(methodName);

            if (opName == null)
            {
                Debug.Fail("Unexpected operator name: '" + methodName + "'.");
                return(methodName);
            }
            else
            {
                return(opName);
            }
        }
Example #4
0
        internal static void AppendParameterTypeDisplayName(NetBrowserManager manager,
                                                            DescriptionBuilder sb, Type type, bool ignoreRef, bool link)
        {
            NetBrowserSettings settings = (NetBrowserSettings)manager.Settings;

            if (type.HasElementType)
            {
                if (type.IsByRef)
                {
                    if (!ignoreRef)
                    {
                        sb.Append(settings.GetKeyword("Type.IsByRef"));
                        sb.Append(" ");
                    }
                    AppendParameterTypeDisplayName(manager, sb, type.GetElementType(), ignoreRef, link);
                }
                else if (type.IsArray)
                {
                    AppendParameterTypeDisplayName(manager, sb, type.GetElementType(), ignoreRef, link);

                    sb.Append(settings.GetKeyword(NetBrowserSettings.KeywordArrayStart));

                    int dimensions = type.GetArrayRank();
                    for (int index = 1; index < dimensions; index++)
                    {
                        sb.Append(",");
                    }

                    sb.Append(settings.GetKeyword(NetBrowserSettings.KeywordArrayEnd));
                }
                else if (type.IsPointer)
                {
                    AppendParameterTypeDisplayName(manager, sb, type.GetElementType(), ignoreRef, link);
                    sb.Append(" *");
                }
                else
                {
                    throw new ApplicationException("Type '" + type.Name + "' has element type, but is not a"
                                                   + " reference type, array or pointer.");
                }
            }
            else
            {
                string keyword = ((NetBrowserSettings)manager.Settings).GetKeyword(type.AssemblyQualifiedName);
                if (keyword == null)
                {
                    if (link)
                    {
                        sb.AppendLink(GetTypeDisplayFullName(type), manager.GetTypeInfoForLink(
                                          type.Assembly.Location, type.FullName));
                    }
                    else
                    {
                        sb.Append(GetTypeDisplayFullName(type));
                    }
                }
                else
                {
                    sb.Append(keyword);                     // We don't want to make keywords into links
                }
            }
        }