public ComField(IComBase parent, ITypeInfo info, string name, VARDESC varDesc, int index, DeclarationType type) { Parent = parent; Name = name; Index = index; Type = type; Flags = (VARFLAGS)varDesc.wVarFlags; if (Type == DeclarationType.Constant) { var value = new ComVariant(varDesc.desc.lpvarValue); DefaultValue = value.Value; if (ComVariant.TypeNames.TryGetValue(value.VariantType, out string typeName)) { _valueType = typeName; } if (value.VariantType.HasFlag(VarEnum.VT_ARRAY)) { IsArray = true; } } else { GetFieldType(varDesc.elemdescVar.tdesc, info); } }
public ComParameter(ELEMDESC elemDesc, ITypeInfo info, string name) { Name = name; var paramDesc = elemDesc.desc.paramdesc; GetParameterType(elemDesc.tdesc, info); IsOptional = paramDesc.wParamFlags.HasFlag(PARAMFLAG.PARAMFLAG_FOPT); if (!paramDesc.wParamFlags.HasFlag(PARAMFLAG.PARAMFLAG_FHASDEFAULT) || string.IsNullOrEmpty(name)) { DefaultAsEnum = string.Empty; return; } //lpVarValue points to a PARAMDESCEX structure, but we don't care about the cBytes here at all. //Offset and dereference the VARIANTARG directly. var defValue = new ComVariant(paramDesc.lpVarValue + Marshal.SizeOf(typeof(ulong))); DefaultValue = defValue.Value; ComEnumeration enumType; if (!IsEnumMember || !ComProject.KnownEnumerations.TryGetValue(_enumGuid, out enumType)) { return; } var member = enumType.Members.FirstOrDefault(m => m.Value == (int)DefaultValue); DefaultAsEnum = member != null ? member.Name : string.Empty; }
public ComEnumerationMember(ITypeInfo info, VARDESC varDesc) { var value = new ComVariant(varDesc.desc.lpvarValue); Value = (int)value.Value; ValueType = value.VariantType; var names = new string[1]; int count; info.GetNames(varDesc.memid, names, names.Length, out count); Debug.Assert(count == 1); Name = names[0]; }
public ComParameter(ComMember parent, ELEMDESC elemDesc, ITypeInfo info, string name) { Debug.Assert(name != null, "Parameter name is null"); Parent = parent; Name = name; var paramDesc = elemDesc.desc.paramdesc; GetParameterType(elemDesc.tdesc, info); IsOptional = paramDesc.wParamFlags.HasFlag(PARAMFLAG.PARAMFLAG_FOPT); IsReturnValue = paramDesc.wParamFlags.HasFlag(PARAMFLAG.PARAMFLAG_FRETVAL); if (!paramDesc.wParamFlags.HasFlag(PARAMFLAG.PARAMFLAG_FHASDEFAULT) || string.IsNullOrEmpty(name)) { return; } //lpVarValue points to a PARAMDESCEX structure, but we don't care about the cBytes here at all. //Offset and dereference the VARIANTARG directly. var defValue = new ComVariant(paramDesc.lpVarValue + Marshal.SizeOf(typeof(ulong))); DefaultValue = defValue.Value; }
public ComField(string name, VARDESC varDesc, int index, DeclarationType type) { Name = name; Index = index; Type = type; Flags = (VARFLAGS)varDesc.wVarFlags; if (Type == DeclarationType.Constant) { var value = new ComVariant(varDesc.desc.lpvarValue); DefaultValue = value.Value; string typeName; ValueType = ComVariant.TypeNames.TryGetValue(value.VariantType, out typeName) ? typeName : "Object"; } else { Debug.Assert(varDesc.varkind == VARKIND.VAR_PERINSTANCE); string typeName; ValueType = ComVariant.TypeNames.TryGetValue((VarEnum)varDesc.elemdescVar.tdesc.vt, out typeName) ? typeName : "Object"; } }