/// <summary>
        /// Serializes a task processor configuration to a dictionary to be stored in Redis.
        /// </summary>
        /// <param name="configuration">The configuration to serialize.</param>
        /// <param name="result">The dictionary where to add the serialized key/value pairs.</param>
        /// <param name="prefix">The prefix to add before each dictionary key.</param>
        internal static void Serialize(ITaskProcessorConfiguration configuration, IDictionary <string, string> result, string prefix)
        {
            if (!string.IsNullOrEmpty(prefix) && !prefix.EndsWith(".", StringComparison.Ordinal))
            {
                prefix = prefix + ".";
            }

            RedisTaskProcessorConfigurationRepository.Serialize(configuration.Tasks, result, prefix + "Tasks");
            RedisTaskProcessorConfigurationRepository.Serialize(configuration.PollingQueues, result, prefix + "PollingQueues");
            RedisTaskProcessorConfigurationRepository.Serialize(configuration.PollingJobs, result, prefix + "PollingJobs");
        }
Exemplo n.º 2
0
        private static IReadOnlyDictionary <string, string> Serialize(ITaskProcessorRuntimeInfo taskProcessorInfo)
        {
            Dictionary <string, string> result = new Dictionary <string, string>()
            {
                { "Id", RedisConverter.ToString(taskProcessorInfo.TaskProcessorId) },
                { "MachineName", RedisConverter.ToString(taskProcessorInfo.MachineName) }
            };

            RedisTaskProcessorConfigurationRepository.Serialize(taskProcessorInfo.Configuration, result, "Configuration");

            return(result);
        }
        private static void Serialize(IPollingJobsConfiguration configuration, IDictionary <string, string> result, string prefix)
        {
            if (!string.IsNullOrEmpty(prefix) && !prefix.EndsWith(".", StringComparison.Ordinal))
            {
                prefix = prefix + ".";
            }

            foreach (IPollingJobConfiguration config in configuration)
            {
                result.Add(
                    string.Concat(prefix, config.ImplementationType.Name, ".Type"),
                    RedisConverter.ToString(config.ImplementationType, false));

                RedisTaskProcessorConfigurationRepository.Serialize(config, result, prefix + config.ImplementationType.Name);
            }
        }
        private static void Serialize(ITaskProcessorPollingQueuesConfiguration configuration, IDictionary <string, string> result, string prefix)
        {
            if (!string.IsNullOrEmpty(prefix) && !prefix.EndsWith(".", StringComparison.Ordinal))
            {
                prefix = prefix + ".";
            }

            foreach (ITaskProcessorPollingQueueConfiguration config in configuration)
            {
                result.Add(
                    string.Concat(prefix, config.Key, ".Type"),
                    RedisConverter.ToString(config.Key));

                result.Add(
                    string.Concat(prefix, config.Key, ".MaxWorkers"),
                    RedisConverter.ToString(config.MaxWorkers));

                RedisTaskProcessorConfigurationRepository.Serialize(config, result, prefix + config.Key);
            }
        }