Exemple #1
0
 /// <summary>
 /// Sets the metadata on the dictionary.
 /// </summary>
 /// <param name="metadata"></param>
 /// <param name="properties"></param>
 void SetMetadata(StateObjectMetadata metadata, IDictionary <string, string> properties)
 {
     properties["ExtraFlags"] = metadata.ExtraFlags?.ToString() ?? "";
     properties["Timeout"]    = metadata.Timeout?.ToString() ?? "";
     properties["Altered"]    = metadata.Altered?.ToString() ?? "";
     properties["LockCookie"] = metadata.LockCookie?.ToString() ?? "";
     properties["LockTime"]   = metadata.LockTime?.ToString() ?? "";
 }
Exemple #2
0
        /// <summary>
        /// Attempts to parse the given metadata values.
        /// </summary>
        /// <param name="properties"></param>
        /// <returns></returns>
        StateObjectMetadata GetMetadata(IDictionary <string, string> properties)
        {
            var metadata = new StateObjectMetadata();

            metadata.ExtraFlags = properties.TryGetValue("ExtraFlags", out var fd) && uint.TryParse(fd, out var fv) ? (uint?)fv : null;
            metadata.Timeout    = properties.TryGetValue("Timeout", out var td) && TimeSpan.TryParse(td, out var tv) ? (TimeSpan?)tv : null;
            metadata.Altered    = properties.TryGetValue("Altered", out var ad) && DateTime.TryParse(ad, out var av) ? (DateTime?)av : null;
            metadata.LockCookie = properties.TryGetValue("LockCookie", out var cd) && uint.TryParse(cd, out var cv) ? (uint?)cv : null;
            metadata.LockTime   = properties.TryGetValue("LockTime", out var ld) && DateTime.TryParse(ld, out var lv) ? (DateTime?)lv : null;
            return(metadata);
        }