public static SnwFieldInfo GetFieldInfo(SnwStructure structure, string fieldName) { RfcFieldDesc fieldDescription; RfcErrorInfo errorInfo; UnsafeNativeMethods.RfcGetFieldDescByName(structure.DataHandle(), fieldName, out fieldDescription, out errorInfo); errorInfo.IfErrorThrowException(); return(new SnwFieldInfo(fieldDescription)); }
public static T GetParameter <T>(this IDataParameter dataContainer, string name, int length, int decimals, RfcType rfcType) { RfcErrorInfo errorInfo; object result; switch (rfcType) { case RfcType.Char: { var buffer = new StringBuilder(length); UnsafeNativeMethods.RfcGetChars(dataContainer.DataHandle(), name, buffer, buffer.Length, out errorInfo); errorInfo.IfErrorThrowException(); result = buffer; } break; case RfcType.Num: { var buffer = new char[length]; UnsafeNativeMethods.RfcGetNum(dataContainer.DataHandle(), name, buffer, buffer.Length, out errorInfo); errorInfo.IfErrorThrowException(); result = new SnwNumeric(new string(buffer)); } break; case RfcType.String: { int stringLength = 200; //UnsafeNativeMethods.RfcGetStringLength(dataContainer.DataHandle(), name, out stringLength, out errorInfo); //errorInfo.IfErrorThrowException(); var stringBuffer = new StringBuilder(stringLength + 1); int retlength; UnsafeNativeMethods.RfcGetString(dataContainer.DataHandle(), name, stringBuffer, stringBuffer.Capacity, out retlength, out errorInfo); errorInfo.IfErrorThrowException(); result = stringBuffer.ToString(); } break; case RfcType.Date: { var date = new char[8]; UnsafeNativeMethods.RfcGetDate(dataContainer.DataHandle(), name, date, out errorInfo); errorInfo.IfErrorThrowException(); result = new SnwDate(new string(date)); } break; case RfcType.Time: { var time = new char[6]; UnsafeNativeMethods.RfcGetTime(dataContainer.DataHandle(), name, time, out errorInfo); errorInfo.IfErrorThrowException(); result = new SnwTime(new string(time)); } break; case RfcType.Byte: { var buffer = new byte[length]; UnsafeNativeMethods.RfcGetBytes(dataContainer.DataHandle(), name, buffer, buffer.Length, out errorInfo); errorInfo.IfErrorThrowException(); result = buffer; } break; case RfcType.Int: { int value; UnsafeNativeMethods.RfcGetInt(dataContainer.DataHandle(), name, out value, out errorInfo); errorInfo.IfErrorThrowException(); result = value; } break; case RfcType.Int1: { byte value; UnsafeNativeMethods.RfcGetInt1(dataContainer.DataHandle(), name, out value, out errorInfo); errorInfo.IfErrorThrowException(); result = value; } break; case RfcType.Int2: { short value; UnsafeNativeMethods.RfcGetInt2(dataContainer.DataHandle(), name, out value, out errorInfo); errorInfo.IfErrorThrowException(); result = value; } break; case RfcType.Float: { double value; UnsafeNativeMethods.RfcGetFloat(dataContainer.DataHandle(), name, out value, out errorInfo); errorInfo.IfErrorThrowException(); result = value; } break; case RfcType.DecF16: { decimal value; UnsafeNativeMethods.RfcGetDecF16(dataContainer.DataHandle(), name, out value, out errorInfo); errorInfo.IfErrorThrowException(); result = value; } break; case RfcType.DecF34: { decimal value; UnsafeNativeMethods.RfcGetDecF16(dataContainer.DataHandle(), name, out value, out errorInfo); errorInfo.IfErrorThrowException(); result = value; } break; case RfcType.XString: { var buffer = new byte[length]; int outLength; UnsafeNativeMethods.RfcGetXString(dataContainer.DataHandle(), name, buffer, buffer.Length, out outLength, out errorInfo); errorInfo.IfErrorThrowException(); result = new SnwXString(buffer); } break; case RfcType.Structure: { IntPtr structureHandle; UnsafeNativeMethods.RfcGetStructure(dataContainer.DataHandle(), name, out structureHandle, out errorInfo); errorInfo.IfErrorThrowException(); var structure = new SnwStructure(structureHandle); result = typeof(T).GetConstructor(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, null, new[] { typeof(SnwStructure) }, null).Invoke(new object[] { structure }); } break; case RfcType.Table: { IntPtr tableHandle; UnsafeNativeMethods.RfcGetTable(dataContainer.DataHandle(), name, out tableHandle, out errorInfo); errorInfo.IfErrorThrowException(); var table = new SnwTable <SnwStructure>(tableHandle); result = typeof(T).GetConstructor(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, null, new[] { typeof(SnwTable <SnwStructure>) }, null).Invoke(new object[] { table }); } break; default: { throw new SnwConnectorException(string.Format(CultureInfo.InvariantCulture, Messages.TypeNotHandled, typeof(T))); } } return((T)result); }
public Bapiret1(Exentials.Snw.SnwConnector.SnwStructure structure) : base(structure) { }
public SnwStructure(SnwStructure structure) { _dataHandle = structure._dataHandle; }