예제 #1
0
        private void Initialize()
        {
            using (ComTypeInfo.tracer.TraceMethod())
            {
                if (this.typeinfo == null)
                {
                    return;
                }
                System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = ComTypeInfo.GetTypeAttr(this.typeinfo);
                this.guid = typeAttr.guid;
                for (int firstUserMethod = ComTypeInfo.FindFirstUserMethod(typeAttr); firstUserMethod < (int)typeAttr.cFuncs; ++firstUserMethod)
                {
                    System.Runtime.InteropServices.ComTypes.FUNCDESC funcDesc = ComTypeInfo.GetFuncDesc(this.typeinfo, firstUserMethod);
                    string nameFromFuncDesc = ComUtil.GetNameFromFuncDesc(this.typeinfo, funcDesc);
                    switch (funcDesc.invkind)
                    {
                    case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_FUNC:
                        this.AddMethod(nameFromFuncDesc, firstUserMethod);
                        break;

                    case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYGET:
                    case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYPUT:
                    case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYPUTREF:
                        this.AddProperty(nameFromFuncDesc, funcDesc, firstUserMethod);
                        break;
                    }
                }
            }
        }
예제 #2
0
        private void Initialize()
        {
            if (this.typeinfo != null)
            {
                System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = GetTypeAttr(this.typeinfo);
                this.guid = typeAttr.guid;
                for (int i = 0; i < typeAttr.cFuncs; i++)
                {
                    string nameFromFuncDesc;
                    System.Runtime.InteropServices.ComTypes.FUNCDESC funcDesc = GetFuncDesc(this.typeinfo, i);
                    if ((funcDesc.wFuncFlags & 1) != 1)
                    {
                        nameFromFuncDesc = ComUtil.GetNameFromFuncDesc(this.typeinfo, funcDesc);
                        switch (funcDesc.invkind)
                        {
                        case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_FUNC:
                            this.AddMethod(nameFromFuncDesc, i);
                            break;

                        case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYGET:
                        case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYPUT:
                        case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYPUTREF:
                            goto Label_0075;
                        }
                    }
                    continue;
Label_0075:
                    this.AddProperty(nameFromFuncDesc, funcDesc, i);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes the typeinfo object.
        /// </summary>
        private void Initialize()
        {
            if (_typeinfo != null)
            {
                COM.TYPEATTR typeattr = GetTypeAttr(_typeinfo);

                // Initialize the type information guid
                _guid = typeattr.guid;

                for (int i = 0; i < typeattr.cFuncs; i++)
                {
                    COM.FUNCDESC funcdesc = GetFuncDesc(_typeinfo, i);
                    if (funcdesc.memid == DISPID_NEWENUM)
                    {
                        NewEnumInvokeKind = funcdesc.invkind;
                    }

                    if ((funcdesc.wFuncFlags & 0x1) == 0x1)
                    {
                        // https://msdn.microsoft.com/library/ee488948.aspx
                        // FUNCFLAGS -- FUNCFLAG_FRESTRICTED = 0x1:
                        //     Indicates that the function should not be accessible from macro languages.
                        //     This flag is intended for system-level functions or functions that type browsers should not display.
                        //
                        // For IUnknown methods (AddRef, QueryInterface and Release) and IDispatch methods (GetTypeInfoCount, GetTypeInfo, GetIDsOfNames and Invoke)
                        // FUNCFLAG_FRESTRICTED (0x1) is set for the 'wFuncFlags' field
                        continue;
                    }

                    string strName = ComUtil.GetNameFromFuncDesc(_typeinfo, funcdesc);

                    switch (funcdesc.invkind)
                    {
                    case COM.INVOKEKIND.INVOKE_PROPERTYGET:
                    case COM.INVOKEKIND.INVOKE_PROPERTYPUT:
                    case COM.INVOKEKIND.INVOKE_PROPERTYPUTREF:
                        AddProperty(strName, funcdesc, i);
                        break;

                    case COM.INVOKEKIND.INVOKE_FUNC:
                        AddMethod(strName, i);
                        break;
                    }
                }
            }
        }
예제 #4
0
        internal static string GetMethodSignatureFromFuncDesc(
            ITypeInfo typeinfo,
            System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc,
            bool isPropertyPut)
        {
            StringBuilder stringBuilder    = new StringBuilder();
            string        nameFromFuncDesc = ComUtil.GetNameFromFuncDesc(typeinfo, funcdesc);

            if (!isPropertyPut)
            {
                string stringFromTypeDesc = ComUtil.GetStringFromTypeDesc(typeinfo, funcdesc.elemdescFunc.tdesc);
                stringBuilder.Append(stringFromTypeDesc + " ");
            }
            stringBuilder.Append(nameFromFuncDesc);
            stringBuilder.Append(" (");
            IntPtr lprgelemdescParam = funcdesc.lprgelemdescParam;
            int    num1 = Marshal.SizeOf(typeof(System.Runtime.InteropServices.ComTypes.ELEMDESC));

            for (int index = 0; index < (int)funcdesc.cParams; ++index)
            {
                System.Runtime.InteropServices.ComTypes.ELEMDESC elemdesc = new System.Runtime.InteropServices.ComTypes.ELEMDESC();
                int num2 = index * num1;
                elemdesc = (System.Runtime.InteropServices.ComTypes.ELEMDESC)Marshal.PtrToStructure(IntPtr.Size != 4 ? (IntPtr)(lprgelemdescParam.ToInt64() + (long)num2) : (IntPtr)(lprgelemdescParam.ToInt32() + num2), typeof(System.Runtime.InteropServices.ComTypes.ELEMDESC));
                string stringFromTypeDesc = ComUtil.GetStringFromTypeDesc(typeinfo, elemdesc.tdesc);
                if (index == 0 && isPropertyPut)
                {
                    stringBuilder.Insert(0, stringFromTypeDesc + " ");
                }
                else
                {
                    stringBuilder.Append(stringFromTypeDesc);
                    if (index < (int)funcdesc.cParams - 1)
                    {
                        stringBuilder.Append(", ");
                    }
                }
            }
            stringBuilder.Append(")");
            return(stringBuilder.ToString());
        }