internal static void WriteParameterAttributes(DescriptionBuilder sb, ParameterDesc parameter) { bool first = true; if (parameter.IsIn) { if (first) { first = false; sb.Append("["); } else { sb.Append(", "); } sb.Append(ComBrowserSettings.GetKeyword(ParameterAttributes.In)); } if (parameter.IsOut) { if (first) { first = false; sb.Append("["); } else { sb.Append(", "); } sb.Append(ComBrowserSettings.GetKeyword(ParameterAttributes.Out)); } if (parameter.IsRetval) { if (first) { first = false; sb.Append("["); } else { sb.Append(", "); } sb.Append(ComBrowserSettings.GetKeyword(ParameterAttributes.Retval)); } if (!first) { sb.Append("] "); } }
public MethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc) { // Initialise the standard member information. string name; string docString; int helpContext; string helpFile; typeInfo.GetDocumentation(funcDesc.memid, out name, out docString, out helpContext, out helpFile); Initialise(MemberTypes.Method, name); // Get the names of the parameters (index 0 corresponds to the method name itself). string[] names = new string[funcDesc.cParams + 1]; int nameCount; typeInfo.GetNames(funcDesc.memid, names, funcDesc.cParams + 1, out nameCount); // Need to account for the return value if there is one. bool includeReturnParam = (VarEnum)funcDesc.elemdescFunc.tdesc.vt != VarEnum.VT_VOID && (VarEnum)funcDesc.elemdescFunc.tdesc.vt != VarEnum.VT_HRESULT; int paramCount = funcDesc.cParams + (includeReturnParam ? 1 : 0); m_parameters = new ParameterDesc[paramCount]; // Iterate over the specified parameters. for (int index = 0; index < funcDesc.cParams; ++index) { // Extract the ELEMDESC. IntPtr ptr = (IntPtr)(funcDesc.lprgelemdescParam.ToInt64() + (long)(Marshal.SizeOf(typeof(ELEMDESC)) * index)); ELEMDESC elemdesc = (ELEMDESC)Marshal.PtrToStructure(ptr, typeof(ELEMDESC)); m_parameters[index] = new ParameterDesc(names[index + 1], GetComType(typeInfo, elemdesc.tdesc), elemdesc.desc.idldesc.wIDLFlags); } // Now add the return value if needed. if (includeReturnParam) { m_parameters[paramCount - 1] = new ParameterDesc("ret", GetComType(typeInfo, funcDesc.elemdescFunc.tdesc) + "*", funcDesc.elemdescFunc.desc.idldesc.wIDLFlags | IDLFLAG.IDLFLAG_FOUT | IDLFLAG.IDLFLAG_FRETVAL); } }