public void Setup()
        {
            this.native = new NATIVE_OPERATIONCONTEXT()
            {
                ulUserID       = Any.Int32,
                nOperationID   = Any.Byte,
                nOperationType = Any.Byte,
                nClientType    = Any.Byte,
                fFlags         = Any.Byte,
            };

            this.managed       = new JET_OPERATIONCONTEXT(ref this.native);
            this.reconstituted = this.managed.GetNativeOperationContext();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets a parameter on the provided session state, used for the lifetime of this session or until reset.
        /// </summary>
        /// <param name="sesid">The session to set the parameter on.</param>
        /// <param name="sesparamid">The ID of the session parameter to set.</param>
        /// <param name="operationContext">An operation context to set.</param>
        /// <returns>An error code.</returns>
        public int JetSetSessionParameter(
            JET_SESID sesid,
            JET_sesparam sesparamid,
            JET_OPERATIONCONTEXT operationContext)
        {
            TraceFunctionCall("JetSetSessionParameter");
            this.CheckSupportsWindows10Features("JetSetSessionParameter");
            int err;

            NATIVE_OPERATIONCONTEXT nativeContext = operationContext.GetNativeOperationContext();
            int dataSize = Marshal.SizeOf(nativeContext);

            err = NativeMethods.JetSetSessionParameter(
                sesid.Value,
                (uint)sesparamid,
                ref nativeContext,
                checked ((int)dataSize));

            return(Err(err));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets a parameter on the provided session state, used for the lifetime of this session or until reset.
        /// </summary>
        /// <param name="sesid">The session to set the parameter on.</param>
        /// <param name="sesparamid">The ID of the session parameter to set.</param>
        /// <param name="operationContext">An operation context to set.</param>
        /// <returns>An error code.</returns>
        public int JetGetSessionParameter(
            JET_SESID sesid,
            JET_sesparam sesparamid,
            out JET_OPERATIONCONTEXT operationContext)
        {
            TraceFunctionCall("JetGetSessionParameter");
            this.CheckSupportsWindows10Features("JetGetSessionParameter");
            int err;
            int actualDataSize;

            NATIVE_OPERATIONCONTEXT nativeContext = new NATIVE_OPERATIONCONTEXT();
            int dataSize = Marshal.SizeOf(nativeContext);

            err = NativeMethods.JetGetSessionParameter(
                sesid.Value,
                (uint)sesparamid,
                out nativeContext,
                dataSize,
                out actualDataSize);

            if (err >= (int)JET_err.Success)
            {
                if (actualDataSize != dataSize)
                {
                    throw new ArgumentException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  "Bad return value. Unexpected data size returned. Expected {0}, but received {1}.",
                                  dataSize,
                                  actualDataSize),
                              "sesparamid");
                }
            }

            operationContext = new JET_OPERATIONCONTEXT(ref nativeContext);

            return(Err(err));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets a parameter on the provided session state, used for the lifetime of this session or until reset.
        /// </summary>
        /// <param name="sesid">The session to set the parameter on.</param>
        /// <param name="sesparamid">The ID of the session parameter to set.</param>
        /// <param name="operationContext">An operation context to set.</param>
        /// <returns>An error code.</returns>
        public int JetGetSessionParameter(
            JET_SESID sesid,
            JET_sesparam sesparamid,
            out JET_OPERATIONCONTEXT operationContext)
        {
            TraceFunctionCall("JetGetSessionParameter");
            this.CheckSupportsWindows10Features("JetGetSessionParameter");
            int err;
            int actualDataSize;

            NATIVE_OPERATIONCONTEXT nativeContext = new NATIVE_OPERATIONCONTEXT();
            int dataSize = Marshal.SizeOf(nativeContext);

            err = NativeMethods.JetGetSessionParameter(
                sesid.Value,
                (uint)sesparamid,
                out nativeContext,
                dataSize,
                out actualDataSize);

            if (err >= (int)JET_err.Success)
            {
                if (actualDataSize != dataSize)
                {
                    throw new ArgumentException(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "Bad return value. Unexpected data size returned. Expected {0}, but received {1}.",
                            dataSize,
                            actualDataSize),
                        "sesparamid");
                }
            }

            operationContext = new JET_OPERATIONCONTEXT(ref nativeContext);

            return Err(err);
        }
Exemplo n.º 5
0
 public static extern int JetSetSessionParameter(
     IntPtr sesid,
     uint sesparamid,
     ref NATIVE_OPERATIONCONTEXT data,
     int dataSize);
Exemplo n.º 6
0
 public static extern int JetGetSessionParameter(
     IntPtr sesid,
     uint sesparamid,
     out NATIVE_OPERATIONCONTEXT data,
     int dataSize,
     out int actualDataSize);
 public static extern int JetGetSessionParameter(
     IntPtr sesid,
     uint sesparamid,
     out NATIVE_OPERATIONCONTEXT data,
     int dataSize,
     out int actualDataSize);
 public static extern int JetSetSessionParameter(
     IntPtr sesid,
     uint sesparamid,
     ref NATIVE_OPERATIONCONTEXT data,
     int dataSize);