예제 #1
0
        /// <summary>
        ///     Traverses the <paramref name="source" /> tree structure recursively counting all of the
        ///     <see cref="Miner.Interop.ID8ListItem" /> in the tree.
        /// </summary>
        /// <param name="source">The list to traverse.</param>
        /// <returns>
        ///     Returns the <see cref="int" /> representing the number of elements in the tree.
        /// </returns>
        public static int Count(this ID8List source)
        {
            if (source == null)
            {
                return(0);
            }

            return(source.Where(o => o != null).Count());
        }
예제 #2
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="ID8List" />
        /// </summary>
        /// <param name="source">An <see cref="ID8List" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <param name="depth">The depth of the recursion.</param>
        /// <returns>
        ///     An <see cref="IEnumerable{T}" /> that contains the list items from the input source.
        /// </returns>
        public static IEnumerable <ID8ListItem> AsEnumerable(this ID8List source, int depth)
        {
            if (source == null)
            {
                return(null);
            }

            return(source.Where(o => o != null, depth).Select(o => o.Value));
        }
예제 #3
0
        /// <summary>
        ///     Traverses the <paramref name="source" /> tree structure recursively selecting only those
        ///     <see cref="Miner.Interop.ID8ListItem" /> that satisify the <paramref name="selector" />
        ///     and flattens the resulting sequences into one sequence.
        /// </summary>
        /// <param name="source">The list to traverse.</param>
        /// <param name="selector">A function to test each element for a condition in each recursion.</param>
        /// <returns>
        ///     Returns an
        ///     <see cref="T:System.Collections.Generic.IEnumerable{Miner.Collections.IRecursion{Miner.Interop.ID8ListItem}}" />
        ///     whose elements
        ///     who are the result of invoking the recursive transform function on each element of the input sequence.
        /// </returns>
        /// <exception cref="ArgumentNullException">selector</exception>
        public static IEnumerable <IRecursion <ID8ListItem> > Where(this ID8List source, Func <ID8ListItem, bool> selector)
        {
            if (source == null)
            {
                return(null);
            }
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }

            return(source.Where(selector, Recursion <ID8ListItem> .Infinity));
        }
예제 #4
0
        /// <summary>
        ///     Traverses the <paramref name="source" /> tree structure recursively counting those
        ///     <see cref="Miner.Interop.ID8ListItem" />
        ///     that satisfies the <paramref name="selector" /> match test.
        /// </summary>
        /// <param name="source">The list to traverse.</param>
        /// <param name="selector">A function to test an element for a condition.</param>
        /// <returns>
        ///     Returns the <see cref="Int32" /> representing the number of elements that match the selector.
        /// </returns>
        /// <exception cref="ArgumentNullException">selector</exception>
        public static int Count(this ID8List source, Func <ID8ListItem, bool> selector)
        {
            if (source == null)
            {
                return(0);
            }
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }

            return(source.Where(selector).Count());
        }
예제 #5
0
        /// <summary>
        ///     Gets the automatic value (i.e. ArcFM Auto Updater) for the specified <paramref name="editEvent" /> and
        ///     <paramref name="guid" />.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <param name="guid">The unique identifier.</param>
        /// <returns>
        ///     Returns a <see cref="IMMAutoValue" /> representing the automatic value; otherwise <c>null</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">guid</exception>
        public static IMMAutoValue GetAutoValue(this IMMSubtype source, mmEditEvent editEvent, Guid guid)
        {
            if (source == null)
            {
                return(null);
            }
            if (guid == Guid.Empty)
            {
                throw new ArgumentNullException("guid");
            }

            ID8List list = source as ID8List;

            if (list == null)
            {
                return(null);
            }

            var values = list.Where(i => i.ItemType == mmd8ItemType.mmitAutoValue, 0).Select(o => o.Value);

            foreach (IMMAutoValue autoValue in values.OfType <IMMAutoValue>().Where(o => o.AutoGenID != null && o.EditEvent == editEvent))
            {
                if (autoValue.AutoGenID.Value == null)
                {
                    continue;
                }

                string autoGenID = autoValue.AutoGenID.Value.ToString();
                if (string.Equals(autoGenID, guid.ToString("B"), StringComparison.InvariantCultureIgnoreCase))
                {
                    return(autoValue);
                }
            }

            return(null);
        }
예제 #6
0
        public void ID8List_Where_Equals_9()
        {
            var iter = _List.Where(o => o.ItemType == mmd8ItemType.mmd8itFeature);

            Assert.AreEqual(9, iter.Count());
        }