/// <summary>
        /// Converts an IntPtr array of context arguments to an object array containing the resolved parameters the pointers point to.
        /// </summary>
        /// <remarks>
        /// Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available
        /// to force them into a certain type.  Therefore the only types you will ever see as parameters are
        /// DBNull.Value, Int64, Double, String or byte[] array.
        /// </remarks>
        /// <param name="nArgs">The number of arguments</param>
        /// <param name="argsptr">A pointer to the array of arguments</param>
        /// <returns>An object array of the arguments once they've been converted to .NET values</returns>
        internal object[] ConvertParams(int nArgs, IntPtr argsptr)
        {
            object[] parms = new object[nArgs];
#if !PLATFORM_COMPACTFRAMEWORK
            IntPtr[] argint = new IntPtr[nArgs];
#else
            int[] argint = new int[nArgs];
#endif
            Marshal.Copy(argsptr, argint, 0, nArgs);

            for (int n = 0; n < nArgs; n++)
            {
                switch (_base.GetParamValueType((IntPtr)argint[n]))
                {
                case TypeAffinity.Null:
                    parms[n] = DBNull.Value;
                    break;

                case TypeAffinity.Int64:
                    parms[n] = _base.GetParamValueInt64((IntPtr)argint[n]);
                    break;

                case TypeAffinity.Double:
                    parms[n] = _base.GetParamValueDouble((IntPtr)argint[n]);
                    break;

                case TypeAffinity.Text:
                    parms[n] = _base.GetParamValueText((IntPtr)argint[n]);
                    break;

                case TypeAffinity.Blob:
                {
                    int    x;
                    byte[] blob;

                    x    = (int)_base.GetParamValueBytes((IntPtr)argint[n], 0, null, 0, 0);
                    blob = new byte[x];
                    _base.GetParamValueBytes((IntPtr)argint[n], 0, blob, 0, x);
                    parms[n] = blob;
                }
                break;

                case TypeAffinity.DateTime: // Never happens here but what the heck, maybe it will one day.
                    parms[n] = _base.ToDateTime(_base.GetParamValueText((IntPtr)argint[n]));
                    break;
                }
            }
            return(parms);
        }
예제 #2
0
        /// <summary>
        /// Converts an IntPtr array of context arguments to an object array containing the resolved parameters the pointers point to.
        /// </summary>
        /// <remarks>
        /// Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available
        /// to force them into a certain type.  Therefore the only types you will ever see as parameters are
        /// DBNull.Value, Int64, Double, String or byte[] array.
        /// </remarks>
        /// <param name="nArgs">The number of arguments</param>
        /// <param name="argsptr">A pointer to the array of arguments</param>
        /// <returns>An object array of the arguments once they've been converted to .NET values</returns>
        internal object[] ConvertParams(int nArgs, SqliteValueHandle[] argsptr)
        {
            object[]            parms  = new object[nArgs];
            SqliteValueHandle[] argint = new SqliteValueHandle[nArgs];
            Array.Copy(argsptr, argint, nArgs);

            for (int n = 0; n < nArgs; n++)
            {
                switch (_base.GetParamValueType((SqliteValueHandle)argint[n]))
                {
                case TypeAffinity.Null:
                    parms[n] = DBNull.Value;
                    break;

                case TypeAffinity.Int64:
                    parms[n] = _base.GetParamValueInt64((SqliteValueHandle)argint[n]);
                    break;

                case TypeAffinity.Double:
                    parms[n] = _base.GetParamValueDouble((SqliteValueHandle)argint[n]);
                    break;

                case TypeAffinity.Text:
                    parms[n] = _base.GetParamValueText((SqliteValueHandle)argint[n]);
                    break;

                case TypeAffinity.Blob:
                {
                    int    x;
                    byte[] blob;

                    x    = (int)_base.GetParamValueBytes((SqliteValueHandle)argint[n], 0, null, 0, 0);
                    blob = new byte[x];
                    _base.GetParamValueBytes((SqliteValueHandle)argint[n], 0, blob, 0, x);
                    parms[n] = blob;
                }
                break;

                case TypeAffinity.DateTime: // Never happens here but what the heck, maybe it will one day.
                    parms[n] = _base.ToDateTime(_base.GetParamValueText((SqliteValueHandle)argint[n]));
                    break;
                }
            }
            return(parms);
        }