Exemplo n.º 1
0
        static void ExpandMatrixApplyPatchValues(ForEachItem fe, XmlDocument source, List <object> matrix)
        {
            foreach (string value in fe.Values)
            {
                XmlNode src = source.SelectSingleNode(fe.Target);
                if (src != null)
                {
                    if (src.NodeType == XmlNodeType.Element)
                    {
                        if (src.SelectNodes("*").Count > 0)
                        {
                            src.InnerXml = RegexReplaceOrValue(src.InnerXml, value, fe);
                        }
                        else
                        {
                            src.InnerText = RegexReplaceOrValue(src.InnerText, value, fe);
                        }
                    }
                    else
                    {
                        src.Value = RegexReplaceOrValue(src.Value, value, fe);
                    }
                }

                if (fe.HasChild)
                {
                    ExpandMatrixApplyPatchValues(fe.Child, source, matrix);
                }
                else
                {
                    matrix.Add((XmlDocument)source.Clone());
                }
            }
        }
Exemplo n.º 2
0
        internal static List <object> ExpandForEachAndApplyPatchValues(ref XmlDocument source, List <ForEachItem> forEach)
        {
            ForEachItem node = forEach[0];

            for (int i = 1; i < forEach.Count; i++)
            {
                node.Child = forEach[i];
                node       = forEach[i];
            }

            List <object> matrix = new List <object>();

            ExpandMatrixApplyPatchValues(forEach[0], source, matrix);

            return(matrix);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Asynchronously runs <paramref name="delegateFunction"/> for every item in the given collection
 /// </summary>
 /// <param name="collection">The collection to be enumerated</param>
 /// <param name="delegateFunction">The function to asynchronously run</param>
 /// <param name="runSynchronously">Whether or not to allow running multiple tasks at once. Defaults to false.</param>
 /// <param name="batchSize">The maximum number of tasks to run at once, or 0 or negative for no limit.</param>
 /// <param name="progressReportToken">Optional token to receive progress updates</param>
 /// <exception cref="InvalidOperationException">Thrown if execution starts before the end of another operation</exception>
 public static async Task RunAsyncForEach(this IEnumerable collection, ForEachItem <object> delegateFunction, bool runSynchronously = false, int batchSize = 0, ProgressReportToken progressReportToken = null)
 {
     await AsyncFor.ForEach(collection, delegateFunction, runSynchronously, batchSize, progressReportToken);
 }