示例#1
0
        protected override Dictionary <string, object> GetSettings(IFileList list)
        {
            if (list.ItemTemplate == null)
            {
                return(null);
            }

            Dictionary <string, object> settings = new Dictionary <string, object>();

            if (string.IsNullOrEmpty(list.Id))
            {
                throw new Exception("FileList Id is required.");
            }
            if (string.IsNullOrEmpty(list.FileSelectorId))
            {
                throw new Exception("FileList FileSelectorId is required.");
            }

            settings["id"] = list.Id;
            settings["templateElement"] = list.Id + "_template";

            if (!string.IsNullOrEmpty(list.FileSelectorId))
            {
                settings["fileSelector"] = list.FileSelectorId;
            }
            else
            {
                // TODO: implement
            }

            if (!string.IsNullOrEmpty(list.InvalidFileSizeMessage))
            {
                settings["invalidFileSizeMessage"] = list.InvalidFileSizeMessage;
            }
            if (!string.IsNullOrEmpty(list.InvalidExtensionMessage))
            {
                settings["invalidExtensionMessage"] = list.InvalidExtensionMessage;
            }
            if (!string.IsNullOrEmpty(list.FileSizeFormatter))
            {
                settings["fileSizeFormatter"] = new LiteralString(list.FileSizeFormatter);
            }
            if (!string.IsNullOrEmpty(list.FileValidationMessageFormatter))
            {
                settings["fileValidationMessageFormatter"] = new LiteralString(list.FileValidationMessageFormatter);
            }

            return(settings);
        }
        protected override Dictionary <string, object> GetSettings(IUploadProgressDisplay display)
        {
            if (display.Template == null)
            {
                return(null);
            }

            Dictionary <string, object> settings = new Dictionary <string, object>();

            settings["id"] = display.Id;

            if (!string.IsNullOrEmpty(display.UploadConnectorId))
            {
                settings["uploadConnector"] = display.UploadConnectorId;
            }
            else
            {
                // TODO: implement
            }

            if (!string.IsNullOrEmpty(display.FileSizeFormatter))
            {
                settings["fileSizeFormatter"] = new LiteralString(display.FileSizeFormatter);
            }
            if (!string.IsNullOrEmpty(display.PercentFormatter))
            {
                settings["percentFormatter"] = new LiteralString(display.PercentFormatter);
            }
            if (!string.IsNullOrEmpty(display.TimeFormatter))
            {
                settings["timeFormatter"] = new LiteralString(display.TimeFormatter);
            }
            if (display.ShowDuringUpload != null)
            {
                settings["showDuringUpload"] = display.ShowDuringUpload;
            }
            if (display.HideAfterUpload != null)
            {
                settings["hideAfterUpload"] = display.HideAfterUpload;
            }

            return(settings);
        }