コード例 #1
0
        protected override async Task ProcessCoreAsync(TagHelperContext context, TagHelperOutput output)
        {
            var model = new FileUploaderModel
            {
                Name                           = Name,
                Path                           = Path,
                UploadUrl                      = UploadUrl,
                UploadText                     = UploadText,
                DisplayRemoveButton            = DisplayRemoveButton,
                DisplayBrowseMediaButton       = DisplayBrowseMediaButton,
                DisplayRemoveButtonAfterUpload = DisplayRemoveButtonAfterUpload,
                HasTemplatePreview             = HasTemplatePreview,
                DownloadEnabled                = DownloadEnabled,
                MultiFile                      = MultiFile,
                TypeFilter                     = TypeFilter,
                PreviewContainerId             = PreviewContainerId,
                MainFileId                     = MainFileId,
                MaxFileSize                    = MaxFileSize,
                EntityType                     = EntityType,
                EntityId                       = EntityId,
                DeleteUrl                      = DeleteUrl,
                SortUrl                        = SortUrl,
                EntityAssignmentUrl            = EntityAssignmentUrl,
                UploadedFiles                  = UploadedFiles,
                OnUploading                    = OnUploading,
                OnUploadCompleted              = OnUploadCompleted,
                OnError                        = OnError,
                OnFileRemoved                  = OnFileRemoved,
                OnAborted                      = OnAborted,
                OnCompleted                    = OnCompleted,
                OnMediaSelected                = OnMediaSelected
            };

            var extensions = _mediaTypeResolver.ParseTypeFilter(TypeFilter.HasValue() ? TypeFilter : "*");

            model.AcceptedFileExtensions = "." + string.Join(",.", extensions);

            var widget  = new ComponentWidgetInvoker("FileUploader", new { model });
            var partial = await widget.InvokeAsync(ViewContext);

            output.TagMode = TagMode.StartTagAndEndTag;
            output.TagName = null;
            output.Content.SetHtmlContent(partial);
        }