コード例 #1
0
        /// <summary>
        /// Processes all configurations in the provided configuration collection
        /// </summary>
        /// <param name="configuration">the current configuration collection</param>
        /// <param name="data">the data that came out of the last query</param>
        private void ProcessConfig(QueryConfigurationCollection configuration, DynamicResult[] data = null)
        {
            QueryConfigurationCollection tmp = currentConfiguration.Value;
            DynamicResult currentTmpItem     = currentItem.Value;

            try
            {
                if (currentTmpItem != null)
                {
                    Parents.Insert(0, currentTmpItem);
                }
                currentConfiguration.Value = configuration;
                if (data != null)
                {
                    foreach (DynamicResult result in data)
                    {
                        currentItem.Value = result;
                        ProcessQueries(configuration);
                    }
                }
                else
                {
                    ProcessQueries(configuration);
                }
            }
            finally
            {
                currentConfiguration.Value = tmp;
                currentItem.Value          = currentTmpItem;
                if (currentTmpItem != null)
                {
                    Parents.RemoveAt(0);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Runs all configured queries in the sequence they were registered in the configuration
        /// </summary>
        /// <param name="queries">the queries to run on the target</param>
        private void ProcessQueries(QueryConfigurationCollection queries)
        {
            Dictionary <string, object> variables = new Dictionary <string, object> {
                { "current", currentItem.Value }, { "parents", Parents.ToArray() }
            };
            QueryDefinition callConfig = new QueryDefinition();

            foreach (QueryConfiguration config in queries)
            {
                callConfig.Query   = config.Query;
                callConfig.Source  = config.Source;
                callConfig.Targets =
                    (from t in config.Targets
                     select new TargetDefinition {
                    TargetName = t.TargetName, RegisterAs = t.RegisterName
                }).ToArray();
                callConfig.Parameters = (from t in config.Parameters
                                         select
                                         new ParameterDefinition
                {
                    ParameterName = t.ParameterName,
                    ParameterValue =
                        ExpressionParser.Parse(t.ParameterExpression,
                                               variables, a => { DefaultCallbacks.PrepareDefaultCallbacks(a.Scope, a.ReplSession); })
                }).ToArray();
                currentCallback.Value(callConfig);
            }
        }
コード例 #3
0
 /// <summary>
 /// Builds a structure and uses the specified query-callback
 /// </summary>
 /// <param name="queryCallback">the query-callback that is used to the get structure-queries</param>
 /// <param name="configuration">the Configuration that must be used for this structurebuild-run</param>
 public void BuildStructure(ExecuteQuery queryCallback, QueryConfigurationCollection configuration)
 {
     currentCallback.Value = queryCallback;
     try
     {
         ProcessConfig(configuration);
     }
     finally
     {
         currentCallback.Value = null;
     }
 }
コード例 #4
0
        /// <summary>
        /// Collects data for a specific configuration name
        /// </summary>
        /// <param name="builderName">the name of the structure-Builder that is associated with this collector-job</param>
        /// <param name="configuration">the query configurations that must be used for collecting data</param>
        /// <param name="parameterCallback">A Callback that can be used to request values of parameters in queries</param>
        /// <returns>a structured DynamicResult-Array</returns>
        public DynamicResult[] CollectData(string builderName, QueryConfigurationCollection configuration, Func <string, object> parameterCallback)
        {
            IStructureBuilder builder = builders[builderName];

            variableCallback.Value = parameterCallback;
            try
            {
                builder.BuildStructure(RunQuery, configuration);
                return(builder.RootCollection);
            }
            finally
            {
                variableCallback.Value = null;
                builder.Clear();
            }
        }