Beispiel #1
0
        /// <summary>
        /// Determines whether the specified <paramref name="state" /> exists in the enumeration of <paramref name="source" />.
        /// </summary>
        /// <param name="source">The enumeration of states.</param>
        /// <param name="state">The state.</param>
        /// <returns>
        /// Returns a <see cref="bool" /> representing <c>true</c> if the state exists; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">state</exception>
        public static bool Contains(this IMMEnumPxState source, IMMPxState state)
        {
            if (source == null)
            {
                return(false);
            }
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            return(source.AsEnumerable().Any(testState => testState.Name == state.Name && testState.NodeType == state.NodeType));
        }
Beispiel #2
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IMMEnumPxState" />
        /// </summary>
        /// <param name="source">An <see cref="IMMEnumPxState" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>An <see cref="IEnumerable{T}" /> that contains the fields from the input source.</returns>
        public static IEnumerable <IMMPxState> AsEnumerable(this IMMEnumPxState source)
        {
            if (source != null)
            {
                source.Reset();
                IMMPxState state = source.Next();
                while (state != null)
                {
                    yield return(state);

                    state = source.Next();
                }
            }
        }