Ejemplo n.º 1
0
        private DescriptionText GetDescription()
        {
            try
            {
                DescriptionBuilder sb = new DescriptionBuilder(true);

                sb.Append("Type Library ");
                sb.AppendName(DisplayName);

                sb.EndFirstLine();
                sb.Append("     ");
                sb.Append(m_filePath);
                sb.EndLine();

                string description = GetDocString();
                if (description != null && description.Length != 0)
                {
                    sb.AppendHeading("Description:");
                    sb.Append(description);
                }

                return(sb.GetText());
            }
            catch (System.Exception ex)
            {
                throw new ApplicationException("Failed to write the type library description for type library '"
                                               + m_filePath + "'.", ex);
            }
        }
Ejemplo n.º 2
0
        private DescriptionText GetDescription()
        {
            try
            {
                DescriptionBuilder sb = new DescriptionBuilder(true);

                sb.Append("Assembly ");
                sb.AppendName(m_assembly.GetName().Name);

                sb.EndFirstLine();
                sb.Append("     ");
                sb.Append(m_assembly.Location);
                sb.EndLine();
                sb.EndLine();

                Manager.AppendCustomAttributes(sb, m_assembly);

                return(sb.GetText());
            }
            catch (System.Exception ex)
            {
                throw new ApplicationException("Failed to write the assembly description for assembly '"
                                               + m_assembly.FullName + "'.", ex);
            }
        }
Ejemplo n.º 3
0
        private DescriptionText GetDescriptionInternal(NetNamespaceBrowserInfo ns, NetTypeBrowserInfo baseType)
        {
            try
            {
                DescriptionBuilder sb = new DescriptionBuilder(true);

                sb.Append(Settings.GetKeyword(GetTypeAccess(m_type)));
                sb.Append(" ");

                AppendTypeAttribute(sb, m_type, TypeAttributes.Abstract);
                AppendTypeAttribute(sb, m_type, TypeAttributes.Sealed);

                sb.Append(Settings.GetKeyword(GetObjectType(m_type)));
                sb.Append(" ");

                sb.AppendName(GetTypeDisplayName(m_type));

                if (baseType != null)
                {
                    sb.Append(" : ");
                    sb.AppendLink(baseType.DisplayName, baseType);
                }

                if (m_type.IsEnum)
                {
                    Type underlying = Enum.GetUnderlyingType(m_type);
                    sb.Append(" (");
                    sb.AppendName(Settings.GetKeyword(underlying.AssemblyQualifiedName));
                    sb.Append(")");
                }

                IElementBrowserInfo container = (ns.IsNullNamespace ? ns.Repository : (IElementBrowserInfo)ns);

                sb.EndFirstLine();
                sb.Append(@"     Member of ");
                sb.AppendLink(container.NodeText, container);
                sb.EndLine();

                return(sb.GetText());
            }
            catch (System.Exception ex)
            {
                throw new ApplicationException("Failed to write the type declaration for type '"
                                               + m_type.FullName + "'.", ex);
            }
        }
Ejemplo n.º 4
0
        private void AppendConstructor(DescriptionBuilder sb, NetBrowserManager manager, ConstructorInfo constructor)
        {
            AppendMethodAttribute(sb, constructor, MethodAttributes.Static);
            sb.AppendName(constructor.DeclaringType.Name);

            sb.Append(" ( ");
            AppendParameters(sb, manager, constructor.GetParameters());
            sb.Append(" )");
        }
Ejemplo n.º 5
0
        private void AppendEvent(DescriptionBuilder sb, NetBrowserManager manager, EventInfo eventInfo)
        {
            sb.Append(Settings.GetKeyword(MemberTypes.Event));
            sb.Append(" ");

            NetTypeBrowserInfo.AppendParameterTypeDisplayName(manager, sb, eventInfo.EventHandlerType, false, true);
            sb.Append(" ");

            sb.AppendName(eventInfo.Name);
        }
Ejemplo n.º 6
0
        private void AppendMethod(DescriptionBuilder sb, NetBrowserManager manager, MethodInfo method)
        {
            AppendMethodAttributes(sb, method);

            NetTypeBrowserInfo.AppendParameterTypeDisplayName(manager, sb, method.ReturnType, false, true);
            sb.Append(" ");

            if (MethodIsOperator(method))
            {
                sb.AppendName(Settings.GetKeyword(method.Name));
            }
            else
            {
                sb.AppendName(method.Name);
            }

            sb.Append(" ( ");
            AppendParameters(sb, manager, method.GetParameters());
            sb.Append(" )");
        }
Ejemplo n.º 7
0
        private static void AppendField(DescriptionBuilder sb, FieldDesc field)
        {
            sb.Append(field.Type);
            sb.Append(" ");

            sb.AppendName(field.Name);

            if (field.Value != null)
            {
                sb.Append(" = ");
                sb.Append(field.Value);
            }
        }
Ejemplo n.º 8
0
        private static void AppendMethod(DescriptionBuilder sb, MethodDesc method)
        {
            if (method.ReturnType != null)
            {
                sb.Append(method.ReturnType);
                sb.Append(" ");
            }

            sb.AppendName(method.Name);

            sb.Append(" ( ");
            AppendParameters(sb, method.Parameters);
            sb.Append(" )");
        }
Ejemplo n.º 9
0
        private void AppendProperty(DescriptionBuilder sb, NetBrowserManager manager, PropertyInfo property)
        {
            // Properties have many of the same attributes as methods, but these attributes are declared
            // on the accessors, not on the properties themselves.

            MethodInfo[] accessors = property.GetAccessors(true);
            Debug.Assert(accessors.Length > 0, "Unable to get the accessors for property '"
                         + property.DeclaringType.ToString() + "." + property.Name
                         + "' - this property should not have been displayed.");

            AppendMethodAttributes(sb, accessors[0]);

            NetTypeBrowserInfo.AppendParameterTypeDisplayName(manager, sb, property.PropertyType, false, true);
            sb.Append(" ");
            sb.AppendName(property.Name);

            if (property.CanRead)
            {
                if (property.CanWrite)
                {
                    sb.Append(" [ get, set ]");
                }
                else
                {
                    sb.Append(" [ get ]");
                }
            }
            else if (property.CanWrite)
            {
                sb.Append(" [ set ]");
            }
            else
            {
                Debug.Fail("Property '" + property.Name + "' is not readable and not writeable.");
            }

            // Show indexer parameters as well (which the VS.NET object browser doesn't do).

            ParameterInfo[] indexers = property.GetIndexParameters();

            if (indexers.Length > 0)
            {
                sb.Append(" ( ");
                AppendParameters(sb, manager, indexers);
                sb.Append(" )");
            }
        }
Ejemplo n.º 10
0
        private void AppendField(DescriptionBuilder sb, NetBrowserManager manager, FieldInfo field)
        {
            AppendFieldAttribute(sb, field, FieldAttributes.Static);
            AppendFieldAttribute(sb, field, FieldAttributes.InitOnly);
            AppendFieldAttribute(sb, field, FieldAttributes.Literal);

            NetTypeBrowserInfo.AppendParameterTypeDisplayName(manager, sb, field.FieldType, false, true);
            sb.Append(" ");

            sb.AppendName(field.Name);

            // Show values of constants, static readonly variables and enum identifiers.

            if (field.IsLiteral || (field.IsStatic && field.IsInitOnly))
            {
                sb.Append(" = ");
                sb.Append(GetConstantDisplayValue(field.GetValue(null), true));
            }
        }
        private DescriptionText GetDescriptionInternal(TypeLibraryBrowserInfo parent)
        {
            try
            {
                DescriptionBuilder sb = new DescriptionBuilder(true);

                sb.Append("namespace ");
                sb.AppendName(m_name);

                sb.EndFirstLine();
                sb.Append(@"     Member of ");
                sb.AppendLink(m_typeLibrary.NodeText, parent);
                sb.EndLine();

                return(sb.GetText());
            }
            catch (System.Exception ex)
            {
                throw new ApplicationException("Failed to write the namespace declaration for namespace '"
                                               + DisplayName + "' (type library '" + m_typeLibrary.DisplayName + "') .", ex);
            }
        }
Ejemplo n.º 12
0
        private static void AppendProperty(DescriptionBuilder sb, PropertyDesc property)
        {
            if (property.ReturnType != null)
            {
                sb.Append(property.ReturnType);
                sb.Append(" ");
            }

            sb.AppendName(property.Name);
            sb.Append(ComTypeBrowserInfo.GetPropertyKind(property));

            // Show indexer parameters as well.

            ParameterDesc[] parameters = property.Parameters;

            if (parameters.Length > 0)
            {
                sb.Append(" ( ");
                AppendParameters(sb, parameters);
                sb.Append(" )");
            }
        }
Ejemplo n.º 13
0
        private DescriptionText GetDescription()
        {
            try
            {
                DescriptionBuilder sb = new DescriptionBuilder(true);

                IntPtr ptr = IntPtr.Zero;
                m_typeInfo.ComType.GetTypeAttr(out ptr);

                try
                {
                    TYPEATTR typeAttr = (TYPEATTR)Marshal.PtrToStructure(ptr, typeof(TYPEATTR));

                    // Type GUID and attributes.

                    sb.Append("[ uuid(");
                    sb.Append(typeAttr.guid.ToString().ToUpper());
                    sb.Append(")");

                    AppendTypeAttribute(sb, typeAttr, TYPEFLAGS.TYPEFLAG_FAGGREGATABLE);
                    AppendTypeAttribute(sb, typeAttr, TYPEFLAGS.TYPEFLAG_FAPPOBJECT);
                    AppendTypeAttribute(sb, typeAttr, TYPEFLAGS.TYPEFLAG_FCONTROL);
                    AppendTypeAttribute(sb, typeAttr, TYPEFLAGS.TYPEFLAG_FLICENSED);
                    AppendTypeAttribute(sb, typeAttr, TYPEFLAGS.TYPEFLAG_FHIDDEN);
                    AppendTypeAttribute(sb, typeAttr, TYPEFLAGS.TYPEFLAG_FNONEXTENSIBLE);
                    AppendTypeAttribute(sb, typeAttr, TYPEFLAGS.TYPEFLAG_FOLEAUTOMATION);
                    AppendTypeAttribute(sb, typeAttr, TYPEFLAGS.TYPEFLAG_FRESTRICTED);

                    sb.Append(" ]");
                    sb.EndLine();

                    // Object type (including interface type for an interface).

                    ObjectType objectType = GetObjectType(typeAttr);

                    if (objectType == ObjectType.Interface)
                    {
                        sb.Append(ComBrowserSettings.GetKeyword(GetInterfaceType(typeAttr)));
                    }
                    else
                    {
                        sb.Append(ComBrowserSettings.GetKeyword(objectType));
                    }
                    sb.Append(" ");
                }
                finally
                {
                    m_typeInfo.ComType.ReleaseTypeAttr(ptr);
                }

                // Name and description.

                sb.AppendName(Marshal.GetTypeInfoName(m_typeInfo.ComType));
                sb.EndFirstLine();

                sb.Append(@"     Member of ");
                sb.AppendLink(Namespace.NodeText, Namespace);
                sb.EndLine();

                string description = GetDocString();
                if (description != null && description.Length != 0)
                {
                    sb.AppendHeading("Description:");
                    sb.Append(description);
                }

                return(sb.GetText());
            }
            catch (System.Exception ex)
            {
                throw new ApplicationException("Failed to write the type declaration for type '"
                                               + Marshal.GetTypeInfoName(m_typeInfo.ComType) + "'.", ex);
            }
        }