コード例 #1
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="ID8EnumListItem" />
        /// </summary>
        /// <param name="source">An <see cref="ID8EnumListItem" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>
        ///     An <see cref="IEnumerable{T}" /> that contains the list items from the input source.
        /// </returns>
        public static IEnumerable <ID8ListItem> AsEnumerable(this ID8EnumListItem source)
        {
            if (source == null)
            {
                return(null);
            }

            return(source.AsEnumerable(Recursion <ID8ListItem> .Infinity));
        }
コード例 #2
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="ID8EnumListItem" />
        /// </summary>
        /// <param name="source">An <see cref="ID8EnumListItem" /> 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 ID8EnumListItem source, int depth)
        {
            if (source == null)
            {
                return(null);
            }

            return(source.Where(o => o != null, depth).Select(o => o.Value));
        }
コード例 #3
0
 /// <summary>
 ///     Executes the specified tree tool using the selected items.
 /// </summary>
 /// <param name="pEnumItems">The enumeration of selected items.</param>
 /// <param name="lItemCount">The number of items selected.</param>
 public virtual void Execute(ID8EnumListItem pEnumItems, int lItemCount)
 {
     try
     {
         InternalExecute(pEnumItems, lItemCount);
     }
     catch (Exception e)
     {
         Log.Error(this.Name, e);
     }
 }
コード例 #4
0
        /// <summary>
        ///     Returns <c>true</c> if the tool should be enabled for the specified selection of items.
        /// </summary>
        /// <param name="pEnumItems">The enumeration of items.</param>
        /// <param name="lItemCount">The item count.</param>
        /// <returns><c>true</c> if the tool should be enabled; otherwise <c>false</c></returns>
        public virtual int get_Enabled(ID8EnumListItem pEnumItems, int lItemCount)
        {
            try
            {
                return(InternalEnabled(pEnumItems, lItemCount));
            }
            catch (Exception e)
            {
                Log.Error(this.Name, e);
            }

            return(0);
        }
コード例 #5
0
        /// <summary>
        ///     Traverses the <paramref name="source" /> tree structure recursively selecting 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 items 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>
        public static IEnumerable <IRecursion <ID8ListItem> > Where(this ID8EnumListItem source, Func <ID8ListItem, bool> selector)
        {
            if (source == null)
            {
                return(null);
            }
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }

            return(source.Where(selector, Recursion <ID8ListItem> .Infinity));
        }
コード例 #6
0
        /// <summary>
        ///     Traverses the <paramref name="source" /> tree structure recursively selecting 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 items to traverse.</param>
        /// <param name="selector">A function to test each element for a condition in each recursion.</param>
        /// <param name="depth">The maximum depth of the 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 ID8EnumListItem source, Func <ID8ListItem, bool> selector, int depth)
        {
            if (source == null)
            {
                return(null);
            }
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }

            return(WhereImpl(source, selector, 0, depth));
        }
コード例 #7
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 items 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 ID8EnumListItem source, Func <ID8ListItem, bool> selector)
        {
            if (source == null)
            {
                return(0);
            }
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }

            return(source.Where(selector).Count());
        }
コード例 #8
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>
        /// <param name="depth">The depth of the recursion.</param>
        /// <param name="maximum">The maximum depth of the 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>
        private static IEnumerable <IRecursion <ID8ListItem> > WhereImpl(ID8EnumListItem source, Func <ID8ListItem, bool> selector, int depth, int maximum)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }

            depth++;

            source.Reset();
            ID8ListItem child;

            while ((child = source.Next()) != null)
            {
                if (selector(child))
                {
                    yield return(new Recursion <ID8ListItem>(depth, child));
                }

                if ((depth <= maximum) || (maximum == Recursion <ID8ListItem> .Infinity))
                {
                    ID8List2 list = child as ID8List2;
                    if (list != null)
                    {
                        ID8EnumListItem children = list.Items;
                        if (children != null)
                        {
                            foreach (var item in WhereImpl(children, selector, depth, maximum))
                            {
                                yield return(item);
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
 /// <summary>
 ///     Executes the tree tool within error handling.
 /// </summary>
 /// <param name="enumItems">The enumeration of items.</param>
 /// <param name="itemCount">The item count.</param>
 protected abstract void InternalExecute(ID8EnumListItem enumItems, int itemCount);
コード例 #10
0
 /// <summary>
 ///     Determines of the tree tool is enabled for the specified selection of items.
 /// </summary>
 /// <param name="enumItems">The enumeration of items.</param>
 /// <param name="itemCount">The item count.</param>
 /// <returns>Returns bitwise flag combination of the <see cref="mmToolState" /> to specify if enabled.</returns>
 protected abstract int InternalEnabled(ID8EnumListItem enumItems, int itemCount);