/// <summary> /// When overridden in a derived class, builds a dictionary of name/value pairs. /// </summary> /// <param name="obj">The object to serialize.</param> /// <param name="serializer">The object that is responsible for the serialization.</param> /// <returns> /// An object that contains key/value pairs that represent the object’s data. /// </returns> public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer) { var entity = obj as Attachments; var result = new Dictionary<string, object>(); if (entity != null) { foreach (var entry in entity) { var attachment = new AttachmentConverter().Serialize(entry.Value, serializer); result.Add(entry.Key.ToString(), attachment.First().Value); } } var root = new Dictionary<string, object>(); root[RedmineKeys.ATTACHMENTS] = result; return root; }
/// <summary> /// When overridden in a derived class, builds a dictionary of name/value pairs. /// </summary> /// <param name="obj">The object to serialize.</param> /// <param name="serializer">The object that is responsible for the serialization.</param> /// <returns> /// An object that contains key/value pairs that represent the object’s data. /// </returns> public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer) { var entity = obj as Attachments; var result = new Dictionary <string, object>(); if (entity != null) { foreach (var entry in entity) { var attachment = new AttachmentConverter().Serialize(entry.Value, serializer); result.Add(entry.Key.ToString(), attachment.First().Value); } } var root = new Dictionary <string, object>(); root[RedmineKeys.ATTACHMENTS] = result; return(root); }