/// <summary> /// Creates a <see cref="ReadCondition" /> to read samples with the desired sample states, view states and instance states. /// </summary> /// <param name="sampleStates">The desired sample states mask.</param> /// <param name="viewStates">The desired view states mask.</param> /// <param name="instanceStates">The desired instance states mask.</param> /// <returns>The newly created <see cref="ReadCondition" /> on success, otherwise <see langword="null"/>.</returns> public ReadCondition CreateReadCondition(SampleStateMask sampleStates, ViewStateMask viewStates, InstanceStateMask instanceStates) { IntPtr native = UnsafeNativeMethods.CreateReadCondition(_native, sampleStates, viewStates, instanceStates); ReadCondition readCondition = null; if (native != IntPtr.Zero) { readCondition = new ReadCondition(native, this); _conditions.Add(readCondition); } return(readCondition); }
/// <summary> /// Deletes a <see cref="ReadCondition" /> attached to the <see cref="DataReader" />. Since <see cref="QueryCondition" /> specializes <see cref="ReadCondition" /> it can /// also be used to delete a <see cref="QueryCondition" />. /// </summary> /// <remarks> /// If the <see cref="ReadCondition" /> is not attached to the <see cref="DataReader" />, the operation will return the error <see cref="ReturnCode.PreconditionNotMet" />. /// </remarks> /// <param name="condition">The <see cref="ReadCondition" /> to be deleted.</param> /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns> public ReturnCode DeleteReadCondition(ReadCondition condition) { if (condition == null) { return(ReturnCode.Ok); } ReturnCode ret = UnsafeNativeMethods.DeleteReadCondition(_native, condition.ToNative()); if (ret == ReturnCode.Ok) { _conditions.Remove(condition); } return(ret); }