/// <summary>
        /// Deserializes a task processor configuration from a Redis dictionary.
        /// </summary>
        /// <param name="values">The dictionary stored in Redis.</param>
        /// <param name="result">The instance where to deserialize the data.</param>
        /// <param name="prefix">The prefix that has been added before each dictionary key during serialization.</param>
        internal static void Deserialize(IReadOnlyDictionary <string, string> values, ITaskProcessorConfiguration result, string prefix)
        {
            if (!string.IsNullOrEmpty(prefix) && !prefix.EndsWith(".", StringComparison.Ordinal))
            {
                prefix = prefix + ".";
            }

            RedisTaskProcessorConfigurationRepository.Deserialize(values, result.Tasks, prefix + "Tasks");
            RedisTaskProcessorConfigurationRepository.Deserialize(values, result.PollingQueues, prefix + "PollingQueues");
            RedisTaskProcessorConfigurationRepository.Deserialize(values, result.PollingJobs, prefix + "PollingJobs");
        }
Example #2
0
        private static ITaskProcessorRuntimeInfo Convert(IReadOnlyDictionary <string, string> values)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            RedisTaskProcessorRuntimeInfo result = new RedisTaskProcessorRuntimeInfo(
                RedisConverter.ParseGuid(values["Id"]),
                values["MachineName"]);

            RedisTaskProcessorConfigurationRepository.Deserialize(values, result.Configuration, "Configuration");

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

            foreach (KeyValuePair <string, string> pair in values.Where(v => v.Key.StartsWith(prefix, StringComparison.Ordinal) && v.Key.EndsWith(".Type", StringComparison.Ordinal)))
            {
                Type implementationType = RedisConverter.ParseType(pair.Value);

                IPollingJobConfiguration config = result.Add(implementationType);

                RedisTaskProcessorConfigurationRepository.Deserialize(values, config, prefix + implementationType.Name);
            }
        }
        private static void Deserialize(IReadOnlyDictionary <string, string> values, ITaskProcessorPollingQueuesConfiguration result, string prefix)
        {
            if (!string.IsNullOrEmpty(prefix) && !prefix.EndsWith(".", StringComparison.Ordinal))
            {
                prefix = prefix + ".";
            }

            foreach (KeyValuePair <string, string> pair in values.Where(v => v.Key.StartsWith(prefix, StringComparison.Ordinal) && v.Key.EndsWith(".Type", StringComparison.Ordinal)))
            {
                string key = pair.Value;

                ITaskProcessorPollingQueueConfiguration config = result.Add(key);

                config.MaxWorkers = RedisConverter.ParseInteger(values[prefix + key + ".MaxWorkers"]);

                RedisTaskProcessorConfigurationRepository.Deserialize(values, config, prefix + key);
            }
        }