예제 #1
0
        private void AddMemberFunctions(SortedList members, int count)
        {
            for (int index = 0; index < count; ++index)
            {
                IntPtr funcptr = IntPtr.Zero;
                m_typeInfo.ComType.GetFuncDesc(index, out funcptr);
                FUNCDESC funcDesc = (FUNCDESC)Marshal.PtrToStructure(funcptr, typeof(FUNCDESC));

                try
                {
                    string memberNodeText;

                    // Only add the method if it is not restricted (removes IUnknown, IDispatch methods etc).

                    if ((funcDesc.wFuncFlags & (short)FUNCFLAGS.FUNCFLAG_FRESTRICTED) == 0)
                    {
                        switch (funcDesc.invkind)
                        {
                        case INVOKEKIND.INVOKE_FUNC:
                            MethodDesc methodDesc = new MethodDesc(m_typeInfo.ComType, funcDesc);
                            memberNodeText = methodDesc.Name + "(" + GetParameterTypes(methodDesc.Parameters) + ")";
                            members.Add(new ComMemberBrowserInfo(this, methodDesc, memberNodeText), memberNodeText);
                            break;

                        case INVOKEKIND.INVOKE_PROPERTYGET:
                        case INVOKEKIND.INVOKE_PROPERTYPUT:
                        case INVOKEKIND.INVOKE_PROPERTYPUTREF:
                            PropertyDesc propertyDesc = new PropertyDesc(m_typeInfo.ComType, funcDesc);
                            memberNodeText = propertyDesc.Name + GetPropertyKind(propertyDesc)
                                             + " (" + GetParameterTypes(propertyDesc.Parameters) + ")";
                            members.Add(new ComMemberBrowserInfo(this, propertyDesc, memberNodeText), memberNodeText);
                            break;

                        default:
                            Debug.Fail("Unexpected value of funcDesc.invkind: " + funcDesc.invkind.ToString());
                            break;
                        }
                    }
                }
                finally
                {
                    m_typeInfo.ComType.ReleaseFuncDesc(funcptr);
                }
            }
        }
예제 #2
0
        internal static string GetPropertyKind(PropertyDesc property)
        {
            if (property.CanGet)
            {
                return(" [ get ]");
            }
            else if (property.CanPut)
            {
                return(" [ put ]");
            }
            else if (property.CanPutRef)
            {
                return(" [ putref ]");
            }

            Debug.Fail("Property '" + property.Name + "' is not gettable, puttable, or putrefable.");
            return(string.Empty);
        }
예제 #3
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(" )");
            }
        }