Exemplo n.º 1
0
        /// <summary>
        /// 序列化数据
        /// </summary>
        /// <inheritdoc />
        /// <remarks>
        /// <para>
        /// Returning dictionary contains the following keys.
        /// 返回字典包含以下键。
        /// You can obtain the state data by using the <see cref="IStorageConnection.GetStateData"/> method.
        /// </para>
        /// <list type="table">
        ///     <listheader>
        ///         <term>Key</term>
        ///         <term>Type</term>
        ///         <term>Deserialize Method</term>
        ///         <description>Notes</description>
        ///     </listheader>
        ///     <item>
        ///         <term><c>SucceededAt</c></term>
        ///         <term><see cref="DateTime"/></term>
        ///         <term><see cref="JobHelper.DeserializeDateTime"/></term>
        ///         <description>Please see the <see cref="SucceededAt"/> property.</description>
        ///     </item>
        ///     <item>
        ///         <term><c>PerformanceDuration</c></term>
        ///         <term><see cref="long"/></term>
        ///         <term>
        ///             <see cref="Int64.Parse(string, IFormatProvider)"/> with
        ///             <see cref="CultureInfo.InvariantCulture"/>
        ///         </term>
        ///         <description>Please see the <see cref="PerformanceDuration"/> property.</description>
        ///     </item>
        ///     <item>
        ///         <term><c>Latency</c></term>
        ///         <term><see cref="long"/></term>
        ///         <term>
        ///             <see cref="Int64.Parse(string, IFormatProvider)"/> with
        ///             <see cref="CultureInfo.InvariantCulture"/>
        ///         </term>
        ///         <description>Please see the <see cref="Latency"/> property.</description>
        ///     </item>
        ///     <item>
        ///         <term><c>Result</c></term>
        ///         <term><see cref="object"/></term>
        ///         <term><see cref="JobHelper.FromJson"/></term>
        ///         <description>
        ///             <para>Please see the <see cref="Result"/> property.</para>
        ///             <para>This key may be missing from the dictionary, when the return
        ///             value was <see langword="null" />. Always check for its existence
        ///             before using it.</para>
        ///         </description>
        ///     </item>
        /// </list>
        /// </remarks>
        public Dictionary <string, string> SerializeData()
        {
            var data = new Dictionary <string, string>
            {
                { "SucceededAt", JobHelper.SerializeDateTime(SucceededAt) },
                { "PerformanceDuration", PerformanceDuration.ToString(CultureInfo.InvariantCulture) },
                { "Latency", Latency.ToString(CultureInfo.InvariantCulture) }
            };

            if (Result != null)
            {
                string serializedResult;

                try
                {
                    serializedResult = JobHelper.ToJson(Result);
                }
                catch (Exception)
                {
                    serializedResult = "Can not serialize the return value";
                }

                if (serializedResult != null)
                {
                    data.Add("Result", serializedResult);
                }
            }

            return(data);
        }
Exemplo n.º 2
0
 public Dictionary <string, string> SerializeData()
 {
     return(new Dictionary <string, string>
     {
         { "SucceededAt", JobHelper.ToStringTimestamp(SucceededAt) },
         { "PerformanceDuration", PerformanceDuration.ToString(CultureInfo.InvariantCulture) },
         { "Latency", Latency.ToString(CultureInfo.InvariantCulture) }
     });
 }
Exemplo n.º 3
0
        public Dictionary <string, string> SerializeData()
        {
            var data = new Dictionary <string, string>
            {
                { "SucceededAt", JobHelper.SerializeDateTime(SucceededAt) },
                { "PerformanceDuration", PerformanceDuration.ToString(CultureInfo.InvariantCulture) },
                { "Latency", Latency.ToString(CultureInfo.InvariantCulture) }
            };

            if (Result != null)
            {
                data.Add("Result", JobHelper.ToJson(Result));
            }

            return(data);
        }