/// <summary> /// Handles the ChildInitialized event of the ForEachQuery ReplicatorActivity. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ReplicatorChildEventArgs"/> instance containing the event data.</param> private void ForEachQuery_ChildInitialized(object sender, ReplicatorChildEventArgs e) { Logger.Instance.WriteMethodEntry(EventIdentifier.ResolveQueriesForEachQueryChildInitialized); string queryXPathFilter = null; try { // Prepare for the execution of the query by pulling the XPath filter // from the definition and assigning it to the find resources activity Definition definition = e.InstanceData as Definition; FindResources runQuery = e.Activity as FindResources; if (runQuery == null || definition == null) { return; } queryXPathFilter = definition.Right; runQuery.XPathFilter = queryXPathFilter; // Also add results from any previous queries // so that the first query could also be used in the filter criteria for the second query // providing for the ability to further refine the result set. runQuery.QueryResults = this.QueryResults; } finally { Logger.Instance.WriteMethodExit(EventIdentifier.ResolveQueriesForEachQueryChildInitialized, "Query XPath filter: '{0}'.", queryXPathFilter); } }
/// <summary> /// Handles the ChildCompleted event of the ForEachQuery ReplicatorActivity. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ReplicatorChildEventArgs"/> instance containing the event data.</param> private void ForEachQuery_ChildCompleted(object sender, ReplicatorChildEventArgs e) { Logger.Instance.WriteMethodEntry(EventIdentifier.ResolveQueriesForEachQueryChildCompleted); try { // Load the results into the query results dictionary // Results will be added even if no resources were found Definition definition = e.InstanceData as Definition; FindResources runQuery = e.Activity as FindResources; if (definition != null && runQuery != null) { this.QueryResults.Add(definition.Left, runQuery.FoundIds); } } finally { Logger.Instance.WriteMethodExit(EventIdentifier.ResolveQueriesForEachQueryChildCompleted); } }