/// <summary> /// Serializes the asynchronous uploading settings to the writer. /// </summary> /// <param name="key">The serialization key.</param> /// <param name="options">The target dictionary.</param> public void SerializeTo(string key, IDictionary <string, object> options) { if (Save.HasValue()) { Func <string, string> encoder = (string url) => upload.IsSelfInitialized ? HttpUtility.UrlDecode(url) : url; var config = new Dictionary <string, object>(); config["saveUrl"] = encoder(Save.GenerateUrl(upload.ViewContext, upload.UrlGenerator)); FluentDictionary.For(config) .Add("saveField", SaveField, () => SaveField.HasValue()) .Add("removeField", RemoveField, () => RemoveField.HasValue()) .Add("autoUpload", AutoUpload, () => AutoUpload.HasValue) .Add("batch", Batch, () => Batch.HasValue); if (Remove.HasValue()) { config["removeUrl"] = encoder(Remove.GenerateUrl(upload.ViewContext, upload.UrlGenerator)); } options.Add(key, config); } }
/// <summary> /// Serializes the asynchronous uploading settings to the writer. /// </summary> /// <param name="writer">The writer object.</param> public void SerializeTo(string key, IClientSideObjectWriter writer) { if (Save.HasValue()) { Func <string, string> encoder = (string url) => upload.IsSelfInitialized ? HttpUtility.UrlDecode(url) : url; var config = new Dictionary <string, object>(); config["saveUrl"] = encoder(Save.GenerateUrl(upload.ViewContext, upload.UrlGenerator)); if (SaveField.HasValue()) { config["saveField"] = SaveField; } if (Remove.HasValue()) { config["removeUrl"] = encoder(Remove.GenerateUrl(upload.ViewContext, upload.UrlGenerator)); } config["autoUpload"] = AutoUpload; writer.AppendObject(key, config); } }