Ejemplo n.º 1
0
        /// <summary>
        ///     Returns all the fragment strings that represent it.
        ///     "1;*;2;@(foo)" gets returned as ["1", "2", "*", "a", "b"], given that @(foo)=["a", "b"]
        ///
        ///     Order is not preserved. Globs are not expanded. Item expressions get replaced with their referring item instances.
        /// </summary>
        public IEnumerable <string> FlattenFragmentsAsStrings()
        {
            foreach (var valueString in Fragments.OfType <ValueFragment>().Select(v => v.ItemSpecFragment))
            {
                yield return(valueString);
            }

            foreach (var globString in Fragments.OfType <GlobFragment>().Select(g => g.ItemSpecFragment))
            {
                yield return(globString);
            }

            foreach (
                var referencedItemString in
                Fragments.OfType <ItemExpressionFragment <P, I> >().SelectMany(f => f.ReferencedItems).Select(v => v.ItemSpecFragment)
                )
            {
                yield return(referencedItemString);
            }
        }