Exemplo n.º 1
0
        /// <summary>
        /// De-serialize a <see cref="TaskProcessorPerformanceReport"/> instance from <see cref="String"/>.
        /// </summary>
        /// <param name="value">The string to de-serialize.</param>
        /// <returns>A <see cref="TaskProcessorPerformanceReport"/> instance de-serialized from the specified string.</returns>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="value"/> is null or empty string.</exception>
        protected static TaskProcessorPerformanceReport DeserializeTaskProcessorPerformanceInfo(string value)
        {
            Trace.WriteLine("ENTER: De-serializing '{0}' to {1} ...".FormatInvariant(value, typeof(TaskProcessorPerformanceReport).Name));

            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentNullException("value");
            }

            string[] values1 = value.Split('#');

            string[] values2 = values1[0].Split(';');

            TaskProcessorPerformanceReport result = new TaskProcessorPerformanceReport(RedisConverter.ParseGuid(values2[0]))
            {
                CpuPercent = RedisConverter.ParseInteger(values2[1]),
                RamPercent = RedisConverter.ParseInteger(values2[2]),
            };

            for (int i = 1; i < values1.Length; i++)
            {
                values2 = values1[i].Split(';');

                result.TasksPerformance.Add(new TaskPerformanceReport(RedisConverter.ParseGuid(values2[0]))
                {
                    CpuPercent = RedisConverter.ParseFloat(values2[1]),
                    RamPercent = RedisConverter.ParseFloat(values2[2]),
                });
            }

            Trace.WriteLine("EXIT: '{0}' de-serialized to {1}.".FormatInvariant(value, typeof(TaskProcessorPerformanceReport).Name));

            return(result);
        }