/// <summary> /// Update an existing Poll /// </summary> /// <param name="repository"> /// The repository. /// </param> /// <param name="pollId"> /// The poll id. /// </param> /// <param name="question"> /// The question. /// </param> /// <param name="closes"> /// The closes. /// </param> /// <param name="isClosedBounded"> /// The is closed bounded. /// </param> /// <param name="allowMultipleChoices"> /// The allow multiple choices. /// </param> /// <param name="showVoters"> /// The show voters. /// </param> /// <param name="questionPath"> /// The question path. /// </param> public static void Update( this IRepository <Poll> repository, [NotNull] int pollId, [NotNull] string question, [CanBeNull] DateTime?closes, [NotNull] bool isClosedBounded, [NotNull] bool allowMultipleChoices, [NotNull] bool showVoters, [CanBeNull] string questionPath) { CodeContracts.VerifyNotNull(repository, nameof(repository)); var flags = new PollFlags { IsClosedBound = isClosedBounded, AllowMultipleChoice = allowMultipleChoices, ShowVoters = showVoters, AllowSkipVote = false }; repository.UpdateOnly( () => new Poll { Question = question, Closes = closes, ObjectPath = questionPath, Flags = flags.BitValue }, p => p.ID == pollId); }
/// <summary> /// Create new Poll /// </summary> /// <param name="repository"> /// The repository. /// </param> /// <param name="userId"> /// The user Id. /// </param> /// <param name="question"> /// The question. /// </param> /// <param name="closes"> /// The closes. /// </param> /// <param name="isClosedBounded"> /// The is closed bounded. /// </param> /// <param name="allowMultipleChoices"> /// The allow multiple choices. /// </param> /// <param name="showVoters"> /// The show voters. /// </param> /// <param name="questionPath"> /// The question path. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> public static int Create( this IRepository <Poll> repository, [NotNull] int userId, [NotNull] string question, [CanBeNull] DateTime?closes, [NotNull] bool isClosedBounded, [NotNull] bool allowMultipleChoices, [NotNull] bool showVoters, [CanBeNull] string questionPath) { CodeContracts.VerifyNotNull(repository, nameof(repository)); var flags = new PollFlags { IsClosedBound = isClosedBounded, AllowMultipleChoice = allowMultipleChoices, ShowVoters = showVoters, AllowSkipVote = false }; return(repository.Insert( new Poll { UserID = userId, Question = question, Closes = closes, ObjectPath = questionPath, Flags = flags.BitValue })); }
/// <summary> /// Polls a File Descriptor for the passed in flags. /// </summary> /// <param name="fd">The descriptor to poll</param> /// <param name="flags">The flags to poll for</param> /// <param name="timeout">The amount of time to wait; -1 for infinite, 0 for immediate return, and a positive number is the number of milliseconds</param> /// <param name="resultFlags">The flags that were returned by the poll call</param> /// <returns> /// Returns a positive number (which is the number of structures with nonzero revent files), 0 for a timeout or no /// descriptors were ready, or -1 on error. /// </returns> internal unsafe static int poll(int fd, PollFlags flags, int timeout, out PollFlags resultFlags) { pollfd pfd = default(pollfd); pfd.fd = fd; pfd.events = flags; int result = poll(&pfd, 1, timeout); resultFlags = pfd.revents; return result; }
protected static Mock<IPollItem> CreatePollItemMock(PollFlags flags) { var item = new Mock<IPollItem>(); item.SetupGet(mock => mock.Events).Returns(flags); item.SetupGet(mock => mock.Socket).Returns(new IntPtr()); return item; }
/// <summary> /// Polls a File Descriptor for the passed in flags. /// </summary> /// <param name="fd">The descriptor to poll</param> /// <param name="flags">The flags to poll for</param> /// <param name="timeout">The amount of time to wait; -1 for infinite, 0 for immediate return, and a positive number is the number of milliseconds</param> /// <param name="resultFlags">The flags that were returned by the poll call</param> /// <returns> /// Returns a positive number (which is the number of structures with nonzero revent files), 0 for a timeout or no /// descriptors were ready, or -1 on error. /// </returns> internal static unsafe int Poll(int fd, PollFlags flags, int timeout, out PollFlags resultFlags) { PollFD pfd = default(PollFD); pfd.FD = fd; pfd.Events = flags; int result = Poll(&pfd, 1, timeout); resultFlags = pfd.REvents; return result; }
/// <summary> /// Polls a File Descriptor for the passed in flags. /// </summary> /// <param name="fd">The descriptor to poll</param> /// <param name="flags">The flags to poll for</param> /// <param name="timeout">The amount of time to wait; -1 for infinite, 0 for immediate return, and a positive number is the number of milliseconds</param> /// <param name="resultFlags">The flags that were returned by the poll call</param> /// <returns> /// Returns a positive number (which is the number of structures with nonzero revent files), 0 for a timeout or no /// descriptors were ready, or -1 on error. /// </returns> internal unsafe static int poll(int fd, PollFlags flags, int timeout, out PollFlags resultFlags) { pollfd pfd = default(pollfd); pfd.fd = fd; pfd.events = flags; int result = poll(&pfd, 1, timeout); resultFlags = pfd.revents; return(result); }
/// <summary> /// Polls a File Descriptor for the passed in flags. /// </summary> /// <param name="fd">The descriptor to poll</param> /// <param name="flags">The flags to poll for</param> /// <param name="timeout">The amount of time to wait; -1 for infinite, 0 for immediate return, and a positive number is the number of milliseconds</param> /// <param name="resultFlags">The flags that were returned by the poll call</param> /// <returns> /// Returns a positive number (which is the number of structures with nonzero revent files), 0 for a timeout or no /// descriptors were ready, or -1 on error. /// </returns> internal static unsafe int Poll(int fd, PollFlags flags, int timeout, out PollFlags resultFlags) { PollFD pfd = default(PollFD); pfd.FD = fd; pfd.Events = flags; int result = Poll(&pfd, 1, timeout); resultFlags = pfd.REvents; return(result); }
public void Dispose() { // Ensure PollThread polls for SessionPollFlags. bool interruptPollThread = false; PollFlags sessionPollFlags = _client.SessionPollFlags; PollFlags pollThreadPollFlags = _client.PollThreadPollFlags; if ((sessionPollFlags & ~pollThreadPollFlags) != 0) { _client.PollThreadPollFlags = sessionPollFlags | pollThreadPollFlags; interruptPollThread = true; } Monitor.Exit(_client.Gate); _client = null !; if (interruptPollThread) { PollThread.InterruptPollThread(); } }