public Type GetFieldType() { return(SnwTypeConverter.ToType(this.RfcType)); }
public static void SetParameter(this IDataParameter dataContainer, string name, object paramValue, int length, int decimals) { RfcErrorInfo errorInfo; var type = paramValue.GetType(); switch (SnwTypeConverter.ToRfcType(type)) { case RfcType.Char: { var value = (char[])paramValue; UnsafeNativeMethods.RfcSetChars(dataContainer.DataHandle(), name, value, value.Length, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.Num: { var value = (SnwNumeric)paramValue; if ((length > 0) && (value.Length > length)) { throw new SnwConnectorException(Messages.MaxParameterLengthError, length); } UnsafeNativeMethods.RfcSetNum(dataContainer.DataHandle(), name, value.ToChar(), value.Length, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.String: { var value = (string)paramValue; UnsafeNativeMethods.RfcSetString(dataContainer.DataHandle(), name, value, value.Length, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.Date: { var value = (SnwDate)paramValue; UnsafeNativeMethods.RfcSetDate(dataContainer.DataHandle(), name, value.ToChar(), out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.Time: { var time = (SnwTime)paramValue; UnsafeNativeMethods.RfcSetTime(dataContainer.DataHandle(), name, time.ToChar(), out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.Byte: { var value = (byte[])paramValue; UnsafeNativeMethods.RfcSetBytes(dataContainer.DataHandle(), name, value, value.Length, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.Int: { UnsafeNativeMethods.RfcSetInt(dataContainer.DataHandle(), name, (int)paramValue, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.Int1: { UnsafeNativeMethods.RfcSetInt1(dataContainer.DataHandle(), name, (byte)paramValue, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.Int2: { UnsafeNativeMethods.RfcSetInt2(dataContainer.DataHandle(), name, (short)paramValue, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.Float: { UnsafeNativeMethods.RfcSetFloat(dataContainer.DataHandle(), name, (double)paramValue, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.DecF16: { UnsafeNativeMethods.RfcSetDecF16(dataContainer.DataHandle(), name, (decimal)paramValue, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.DecF34: { UnsafeNativeMethods.RfcSetDecF34(dataContainer.DataHandle(), name, (decimal)paramValue, out errorInfo); errorInfo.IfErrorThrowException(); } break; case RfcType.XString: { var value = (SnwXString)paramValue; UnsafeNativeMethods.RfcSetXString(dataContainer.DataHandle(), name, value.ToByteArray(), value.Length, out errorInfo); errorInfo.IfErrorThrowException(); } break; default: { throw new SnwConnectorException(string.Format(CultureInfo.InvariantCulture, Messages.TypeNotHandled, type)); } } }
public Type GetParameterType() { return(SnwTypeConverter.ToType(RfcType)); }