public ConvertToActionWizard(ConvertToAction fixedConvertToAction) { if (fixedConvertToAction == null) throw new ArgumentNullException(nameof(fixedConvertToAction)); InitializeComponent(); m_fixedConvertToAction = fixedConvertToAction; m_direction = fixedConvertToAction.Direction; m_byref = fixedConvertToAction.ByRef; m_managedType = fixedConvertToAction.ManagedTypeConvertTo; m_marshalAs = fixedConvertToAction.UnmanagedTypeMarshalAs; m_attributes = fixedConvertToAction.Attributes; }
public IAction Create(Dictionary <string, string> parameters) { ConvertToAction convertToAction = new ConvertToAction(); if (parameters.ContainsKey(ParameterDirection)) { convertToAction.Direction = parameters[ParameterDirection]; } else { throw new NoActionParameterException(ActionName, ParameterDirection); } if (parameters.ContainsKey(ParameterByRef)) { convertToAction.ByRef = Boolean.Parse(parameters[ParameterByRef]); } else { throw new NoActionParameterException(ActionName, ParameterByRef); } if (parameters.ContainsKey(ParameterManagedType)) { convertToAction.ManagedTypeConvertTo = parameters[ParameterManagedType]; } else { throw new NoActionParameterException(ActionName, ParameterManagedType); } if (parameters.ContainsKey(ParameterMarshalAs)) { convertToAction.UnmanagedTypeMarshalAs = parameters[ParameterMarshalAs]; } else { throw new NoActionParameterException(ActionName, ParameterMarshalAs); } if (parameters.ContainsKey(ParameterAttributes)) { convertToAction.Attributes = parameters[ParameterAttributes]; } else { throw new NoActionParameterException(ActionName, ParameterAttributes); } return(convertToAction); }
public IAction Create(Dictionary<string, string> parameters) { if (parameters == null) throw new ArgumentNullException(nameof(parameters)); var convertToAction = new ConvertToAction(); if (parameters.ContainsKey(ParameterDirection)) { convertToAction.Direction = parameters[ParameterDirection]; } else { throw new NoActionParameterException(ActionName, ParameterDirection); } if (parameters.ContainsKey(ParameterByRef)) { convertToAction.ByRef = Boolean.Parse(parameters[ParameterByRef]); } else { throw new NoActionParameterException(ActionName, ParameterByRef); } if (parameters.ContainsKey(ParameterManagedType)) { convertToAction.ManagedTypeConvertTo = parameters[ParameterManagedType]; } else { throw new NoActionParameterException(ActionName, ParameterManagedType); } if (parameters.ContainsKey(ParameterMarshalAs)) { convertToAction.UnmanagedTypeMarshalAs = parameters[ParameterMarshalAs]; } else { throw new NoActionParameterException(ActionName, ParameterMarshalAs); } if (parameters.ContainsKey(ParameterAttributes)) { convertToAction.Attributes = parameters[ParameterAttributes]; } else { throw new NoActionParameterException(ActionName, ParameterAttributes); } return convertToAction; }
public IAction Create() { var convertToAction = new ConvertToAction(); return convertToAction; }
private bool DoConvertToActionWizard(ConvertToAction action) { ConvertToActionWizard convertToActionWizard; if (action != null && action.IsInitialized) convertToActionWizard = new ConvertToActionWizard(action); else convertToActionWizard = new ConvertToActionWizard(); DialogResult dialogResult = convertToActionWizard.ShowDialog(); if (dialogResult == DialogResult.OK) { action.Direction = convertToActionWizard.Direction; action.ByRef = Boolean.Parse(convertToActionWizard.ByRef.ToString()); action.ManagedTypeConvertTo = convertToActionWizard.ManagedType; action.UnmanagedTypeMarshalAs = convertToActionWizard.MarshalAs; action.Attributes = convertToActionWizard.Attributes; action.IsInitialized = true; return true; } return false; }
private static void GetTypeFromConvertToAction(SignatureInfoMatchTarget target, ConvertToAction convertToAction, ConverterInfo converterInfo, TypeInfo typeInfo, TypeDesc typeDesc, out Type typeReturn, out CustomAttributeBuilder customAttribute, out ParameterAttributes fixedParameterAttributes) { typeReturn = null; customAttribute = null; fixedParameterAttributes = ParameterAttributes.None; ParameterDirection direction = ConvertToActionConstants.GetParameterDirection(convertToAction.Direction); switch (direction) { case ParameterDirection.IN: fixedParameterAttributes |= ParameterAttributes.In; break; case ParameterDirection.OUT: fixedParameterAttributes |= ParameterAttributes.Out; break; case ParameterDirection.INOUT: fixedParameterAttributes |= ParameterAttributes.In; fixedParameterAttributes |= ParameterAttributes.Out; break; } Dictionary<string, string> attributePairDictionary = ConvertToAction.GetConvertToAttributeDictionary(convertToAction.Attributes); ManagedTypeConvertTo managedType = ConvertToActionConstants.GetManagedTypeConvertTo(convertToAction.ManagedTypeConvertTo); UnmanagedType marshalAs = ConvertToActionConstants.GetMarshalAs(convertToAction.UnmanagedTypeMarshalAs); switch (managedType) { case ManagedTypeConvertTo.LPARRAY: if ((VarEnum)typeDesc.vt == VarEnum.VT_CARRAY || (VarEnum)typeDesc.vt == VarEnum.VT_PTR) { TypeConverter elemTypeConverter = new TypeConverter(converterInfo, typeInfo, typeDesc.lptdesc, ConversionType.Element); Type elemType = elemTypeConverter.ConvertedType; typeReturn = elemType.MakeArrayType(); if (attributePairDictionary.ContainsKey(ConvertToActionDef.SizeConst)) { customAttribute = CustomAttributeHelper.GetBuilderForMarshalAsConstArray(UnmanagedType.LPArray, Int32.Parse(attributePairDictionary[ConvertToActionDef.SizeConst].ToString())); } else if (attributePairDictionary.ContainsKey(ConvertToActionDef.SizeParamIndex)) { customAttribute = CustomAttributeHelper.GetBuilderForMarshalAsConstArrayBySizeParamIndex( UnmanagedType.LPArray, Int16.Parse(attributePairDictionary[ConvertToActionDef.SizeParamIndex].ToString())); } else if (attributePairDictionary.ContainsKey(ConvertToActionDef.SizeParamIndexOffset)) { customAttribute = CustomAttributeHelper.GetBuilderForMarshalAsConstArrayBySizeParamIndex( UnmanagedType.LPArray, (short)((target.NativeParameterIndex) - 1 + Int16.Parse(attributePairDictionary[ConvertToActionDef.SizeParamIndexOffset].ToString()))); } else { customAttribute = CustomAttributeHelper.GetBuilderForMarshalAs(UnmanagedType.LPArray); } } else { string targetTypeString = new TlbType2String(typeInfo, typeDesc).GetTypeString(); throw new TlbImpGeneralException(Resource.FormatString("Err_ConvertNonArrayToArray", targetTypeString), ErrorCode.Err_ConvertNonArrayToArray); } break; case ManagedTypeConvertTo.DECIMAL: typeReturn = typeof(Decimal); if (marshalAs != (UnmanagedType)(-1)) customAttribute = CustomAttributeHelper.GetBuilderForMarshalAs(marshalAs); break; case ManagedTypeConvertTo.INT: typeReturn = typeof(int); if (marshalAs != (UnmanagedType)(-1)) customAttribute = CustomAttributeHelper.GetBuilderForMarshalAs(marshalAs); break; case ManagedTypeConvertTo.OBJECT: typeReturn = typeof(object); if (marshalAs != (UnmanagedType)(-1)) customAttribute = CustomAttributeHelper.GetBuilderForMarshalAs(marshalAs); break; case ManagedTypeConvertTo.STRING: typeReturn = typeof(string); if (marshalAs != (UnmanagedType)(-1)) customAttribute = CustomAttributeHelper.GetBuilderForMarshalAs(marshalAs); break; case ManagedTypeConvertTo.STRINGBUILDER: typeReturn = typeof(StringBuilder); if (marshalAs != (UnmanagedType)(-1)) customAttribute = CustomAttributeHelper.GetBuilderForMarshalAs(marshalAs); break; } if (convertToAction.ByRef) { typeReturn = typeReturn.MakeByRefType(); } }
public IAction Create() { ConvertToAction convertToAction = new ConvertToAction(); return(convertToAction); }