Răsfoiți Sursa

清理代码

懒得勤快 2 ani în urmă
părinte
comite
f100bf46aa
25 a modificat fișierele cu 472 adăugiri și 534 ștergeri
  1. 2 1
      Masuit.Tools.AspNetCore/AspNetCore/DbSetExtensions.cs
  2. 27 31
      Masuit.Tools.AspNetCore/AspNetCore/Executor/ResumeFileContentResultExecutor.cs
  3. 27 31
      Masuit.Tools.AspNetCore/AspNetCore/Executor/ResumeFileStreamResultExecutor.cs
  4. 27 31
      Masuit.Tools.AspNetCore/AspNetCore/Executor/ResumePhysicalFileResultExecutor.cs
  5. 23 24
      Masuit.Tools.AspNetCore/AspNetCore/Executor/ResumeVirtualFileResultExecutor.cs
  6. 19 20
      Masuit.Tools.AspNetCore/AspNetCore/Extensions/ActionContextExtension.cs
  7. 158 160
      Masuit.Tools.AspNetCore/AspNetCore/Extensions/ControllerExtensions.cs
  8. 13 14
      Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/IResumeFileResult.cs
  9. 34 38
      Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/ResumeFileContentResult.cs
  10. 34 39
      Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/ResumeFileStreamResult.cs
  11. 33 37
      Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/ResumePhysicalFileResult.cs
  12. 33 37
      Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/ResumeVirtualFileResult.cs
  13. 1 6
      Masuit.Tools.AspNetCore/AspNetCore/ServiceCollectionExtensions.cs
  14. 1 1
      Masuit.Tools.AspNetCore/AspNetCore/UpdateIgnoreAttribute.cs
  15. 1 2
      Masuit.Tools.AspNetCore/Extensions/DisableFormValueModelBindingAttribute.cs
  16. 2 3
      Masuit.Tools.AspNetCore/Extensions/DistributedCacheExt.cs
  17. 0 3
      Masuit.Tools.AspNetCore/Extensions/IMultipartRequestService.cs
  18. 1 8
      Masuit.Tools.AspNetCore/Extensions/MultipartRequestService.cs
  19. 2 4
      Masuit.Tools.AspNetCore/Extensions/QueryWithNoLockDbCommandInterceptor.cs
  20. 1 2
      Masuit.Tools.AspNetCore/Extensions/ServiceCollectionExt.cs
  21. 0 1
      Masuit.Tools.AspNetCore/Extensions/ViewDataDictionaryExt.cs
  22. 1 4
      Masuit.Tools.AspNetCore/ModelBinder/BodyOrDefaultModelBinder.cs
  23. 1 3
      Masuit.Tools.AspNetCore/ModelBinder/BodyOrDefaultModelBinderProviderSetup.cs
  24. 1 2
      Masuit.Tools.AspNetCore/ModelBinder/FromBodyOrDefaultAttribute.cs
  25. 30 32
      Masuit.Tools.AspNetCore/Net/WebExtension.cs

+ 2 - 1
Masuit.Tools.AspNetCore/AspNetCore/DbSetExtensions.cs

@@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
 using System.ComponentModel.DataAnnotations;
 using System.Linq.Expressions;
 using System.Reflection;
+
 namespace Masuit.Tools.Core.AspNetCore;
 
 public static class DbSetExtensions
@@ -189,4 +190,4 @@ public static class DbSetExtensions
         return query.OrderBy(_ => EF.Functions.Random());
     }
 #endif
-}
+}

+ 27 - 31
Masuit.Tools.AspNetCore/AspNetCore/Executor/ResumeFileContentResultExecutor.cs

@@ -2,45 +2,41 @@
 using Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Threading.Tasks;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor;
+
+/// <summary>
+/// 断点续传文件FileResult执行器
+/// </summary>
+internal class ResumeFileContentResultExecutor : FileContentResultExecutor, IActionResultExecutor<ResumeFileContentResult>
 {
     /// <summary>
-    /// 断点续传文件FileResult执行器
+    /// 构造函数
     /// </summary>
-    internal class ResumeFileContentResultExecutor : FileContentResultExecutor, IActionResultExecutor<ResumeFileContentResult>
+    /// <param name="loggerFactory"></param>
+    public ResumeFileContentResultExecutor(ILoggerFactory loggerFactory) : base(loggerFactory)
     {
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="loggerFactory"></param>
-        public ResumeFileContentResultExecutor(ILoggerFactory loggerFactory) : base(loggerFactory)
+    }
+
+    /// <summary>
+    /// 执行Result
+    /// </summary>
+    /// <param name="context"></param>
+    /// <param name="result"></param>
+    /// <returns></returns>
+    public virtual Task ExecuteAsync(ActionContext context, ResumeFileContentResult result)
+    {
+        if (context == null)
         {
+            throw new ArgumentNullException(nameof(context));
         }
 
-        /// <summary>
-        /// 执行Result
-        /// </summary>
-        /// <param name="context"></param>
-        /// <param name="result"></param>
-        /// <returns></returns>
-        public virtual Task ExecuteAsync(ActionContext context, ResumeFileContentResult result)
+        if (result == null)
         {
-            if (context == null)
-            {
-                throw new ArgumentNullException(nameof(context));
-            }
-
-            if (result == null)
-            {
-                throw new ArgumentNullException(nameof(result));
-            }
-
-            context.SetContentDispositionHeaderInline(result);
-            return base.ExecuteAsync(context, result);
+            throw new ArgumentNullException(nameof(result));
         }
+
+        context.SetContentDispositionHeaderInline(result);
+        return base.ExecuteAsync(context, result);
     }
-}
+}

+ 27 - 31
Masuit.Tools.AspNetCore/AspNetCore/Executor/ResumeFileStreamResultExecutor.cs

@@ -2,46 +2,42 @@
 using Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Threading.Tasks;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor;
+
+/// <summary>
+/// 可断点续传的FileStreamResult执行器
+/// </summary>
+internal class ResumeFileStreamResultExecutor : FileStreamResultExecutor, IActionResultExecutor<ResumeFileStreamResult>
 {
     /// <summary>
-    /// 可断点续传的FileStreamResult执行器
+    /// 构造函数
     /// </summary>
-    internal class ResumeFileStreamResultExecutor : FileStreamResultExecutor, IActionResultExecutor<ResumeFileStreamResult>
+    /// <param name="loggerFactory"></param>
+    public ResumeFileStreamResultExecutor(ILoggerFactory loggerFactory) : base(loggerFactory)
     {
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="loggerFactory"></param>
-        public ResumeFileStreamResultExecutor(ILoggerFactory loggerFactory) : base(loggerFactory)
+    }
+
+    /// <summary>
+    /// 执行Result
+    /// </summary>
+    /// <param name="context"></param>
+    /// <param name="result"></param>
+    /// <returns></returns>
+    public virtual Task ExecuteAsync(ActionContext context, ResumeFileStreamResult result)
+    {
+        if (context == null)
         {
+            throw new ArgumentNullException(nameof(context));
         }
 
-        /// <summary>
-        /// 执行Result
-        /// </summary>
-        /// <param name="context"></param>
-        /// <param name="result"></param>
-        /// <returns></returns>
-        public virtual Task ExecuteAsync(ActionContext context, ResumeFileStreamResult result)
+        if (result == null)
         {
-            if (context == null)
-            {
-                throw new ArgumentNullException(nameof(context));
-            }
-
-            if (result == null)
-            {
-                throw new ArgumentNullException(nameof(result));
-            }
+            throw new ArgumentNullException(nameof(result));
+        }
 
-            context.SetContentDispositionHeaderInline(result);
+        context.SetContentDispositionHeaderInline(result);
 
-            return base.ExecuteAsync(context, result);
-        }
+        return base.ExecuteAsync(context, result);
     }
-}
+}

+ 27 - 31
Masuit.Tools.AspNetCore/AspNetCore/Executor/ResumePhysicalFileResultExecutor.cs

@@ -2,45 +2,41 @@
 using Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Threading.Tasks;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor;
+
+/// <summary>
+/// 通过本地文件的可断点续传的FileResult执行器
+/// </summary>
+internal class ResumePhysicalFileResultExecutor : PhysicalFileResultExecutor, IActionResultExecutor<ResumePhysicalFileResult>
 {
     /// <summary>
-    /// 通过本地文件的可断点续传的FileResult执行器
+    /// 构造函数
     /// </summary>
-    internal class ResumePhysicalFileResultExecutor : PhysicalFileResultExecutor, IActionResultExecutor<ResumePhysicalFileResult>
+    /// <param name="loggerFactory"></param>
+    public ResumePhysicalFileResultExecutor(ILoggerFactory loggerFactory) : base(loggerFactory)
     {
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="loggerFactory"></param>
-        public ResumePhysicalFileResultExecutor(ILoggerFactory loggerFactory) : base(loggerFactory)
+    }
+
+    /// <summary>
+    /// 执行Result
+    /// </summary>
+    /// <param name="context"></param>
+    /// <param name="result"></param>
+    /// <returns></returns>
+    public virtual Task ExecuteAsync(ActionContext context, ResumePhysicalFileResult result)
+    {
+        if (context == null)
         {
+            throw new ArgumentNullException(nameof(context));
         }
 
-        /// <summary>
-        /// 执行Result
-        /// </summary>
-        /// <param name="context"></param>
-        /// <param name="result"></param>
-        /// <returns></returns>
-        public virtual Task ExecuteAsync(ActionContext context, ResumePhysicalFileResult result)
+        if (result == null)
         {
-            if (context == null)
-            {
-                throw new ArgumentNullException(nameof(context));
-            }
-
-            if (result == null)
-            {
-                throw new ArgumentNullException(nameof(result));
-            }
-
-            context.SetContentDispositionHeaderInline(result);
-            return base.ExecuteAsync(context, result);
+            throw new ArgumentNullException(nameof(result));
         }
+
+        context.SetContentDispositionHeaderInline(result);
+        return base.ExecuteAsync(context, result);
     }
-}
+}

+ 23 - 24
Masuit.Tools.AspNetCore/AspNetCore/Executor/ResumeVirtualFileResultExecutor.cs

@@ -3,38 +3,37 @@ using Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor;
+
+/// <summary>
+/// 使用本地虚拟路径的可断点续传的FileResult
+/// </summary>
+internal class ResumeVirtualFileResultExecutor : VirtualFileResultExecutor, IActionResultExecutor<ResumeVirtualFileResult>
 {
     /// <summary>
-    /// 使用本地虚拟路径的可断点续传的FileResult
+    /// 执行FileResult
     /// </summary>
-    internal class ResumeVirtualFileResultExecutor : VirtualFileResultExecutor, IActionResultExecutor<ResumeVirtualFileResult>
+    /// <param name="context"></param>
+    /// <param name="result"></param>
+    /// <returns></returns>
+    public virtual Task ExecuteAsync(ActionContext context, ResumeVirtualFileResult result)
     {
-        /// <summary>
-        /// 执行FileResult
-        /// </summary>
-        /// <param name="context"></param>
-        /// <param name="result"></param>
-        /// <returns></returns>
-        public virtual Task ExecuteAsync(ActionContext context, ResumeVirtualFileResult result)
+        if (context == null)
         {
-            if (context == null)
-            {
-                throw new ArgumentNullException(nameof(context));
-            }
-
-            if (result == null)
-            {
-                throw new ArgumentNullException(nameof(result));
-            }
-
-            context.SetContentDispositionHeaderInline(result);
-
-            return base.ExecuteAsync(context, result);
+            throw new ArgumentNullException(nameof(context));
         }
 
-        public ResumeVirtualFileResultExecutor(ILoggerFactory loggerFactory, IWebHostEnvironment hostingEnvironment) : base(loggerFactory, hostingEnvironment)
+        if (result == null)
         {
+            throw new ArgumentNullException(nameof(result));
         }
+
+        context.SetContentDispositionHeaderInline(result);
+
+        return base.ExecuteAsync(context, result);
+    }
+
+    public ResumeVirtualFileResultExecutor(ILoggerFactory loggerFactory, IWebHostEnvironment hostingEnvironment) : base(loggerFactory, hostingEnvironment)
+    {
     }
 }

+ 19 - 20
Masuit.Tools.AspNetCore/AspNetCore/Extensions/ActionContextExtension.cs

@@ -2,32 +2,31 @@
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Net.Http.Headers;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.Extensions
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.Extensions;
+
+/// <summary>
+/// ResumeFileHelper
+/// </summary>
+public static class ActionContextExtension
 {
     /// <summary>
-    /// ResumeFileHelper
+    /// 设置响应头ContentDispositionHeader
     /// </summary>
-    public static class ActionContextExtension
+    /// <param name="context"></param>
+    /// <param name="result"></param>
+    public static void SetContentDispositionHeaderInline(this ActionContext context, IResumeFileResult result)
     {
-        /// <summary>
-        /// 设置响应头ContentDispositionHeader
-        /// </summary>
-        /// <param name="context"></param>
-        /// <param name="result"></param>
-        public static void SetContentDispositionHeaderInline(this ActionContext context, IResumeFileResult result)
+        context.HttpContext.Response.Headers[HeaderNames.AccessControlExposeHeaders] = HeaderNames.ContentDisposition;
+        if (string.IsNullOrEmpty(result.FileDownloadName))
         {
-            context.HttpContext.Response.Headers[HeaderNames.AccessControlExposeHeaders] = HeaderNames.ContentDisposition;
-            if (string.IsNullOrEmpty(result.FileDownloadName))
-            {
-                var contentDisposition = new ContentDispositionHeaderValue("inline");
-
-                if (!string.IsNullOrWhiteSpace(result.FileInlineName))
-                {
-                    contentDisposition.SetHttpFileName(result.FileInlineName);
-                }
+            var contentDisposition = new ContentDispositionHeaderValue("inline");
 
-                context.HttpContext.Response.Headers[HeaderNames.ContentDisposition] = contentDisposition.ToString();
+            if (!string.IsNullOrWhiteSpace(result.FileInlineName))
+            {
+                contentDisposition.SetHttpFileName(result.FileInlineName);
             }
+
+            context.HttpContext.Response.Headers[HeaderNames.ContentDisposition] = contentDisposition.ToString();
         }
     }
-}
+}

+ 158 - 160
Masuit.Tools.AspNetCore/AspNetCore/Extensions/ControllerExtensions.cs

@@ -1,183 +1,181 @@
-using Masuit.Tools.Mime;
-using Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
+using Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
+using Masuit.Tools.Mime;
 using Microsoft.AspNetCore.Mvc;
-using System.IO;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.Extensions
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.Extensions;
+
+/// <summary>
+/// Controller扩展方法
+/// </summary>
+public static class ControllerExtensions
 {
+    private static readonly IMimeMapper MimeMapper = new MimeMapper();
+
     /// <summary>
-    /// Controller扩展方法
+    /// 可断点续传和多线程下载的FileResult
     /// </summary>
-    public static class ControllerExtensions
+    /// <param name="controller"></param>
+    /// <param name="fileContents">文件二进制流</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <returns></returns>
+    public static ResumeFileContentResult ResumeFile(this ControllerBase controller, byte[] fileContents, string contentType, string fileDownloadName)
     {
-        private static readonly IMimeMapper _mimeMapper = new MimeMapper();
-
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="fileContents">文件二进制流</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <returns></returns>
-        public static ResumeFileContentResult ResumeFile(this ControllerBase controller, byte[] fileContents, string contentType, string fileDownloadName)
-        {
-            return ResumeFile(controller, fileContents, contentType, fileDownloadName, null);
-        }
+        return ResumeFile(controller, fileContents, contentType, fileDownloadName, null);
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="fileContents">文件二进制流</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <returns></returns>
-        public static ResumeFileContentResult ResumeFile(this ControllerBase controller, byte[] fileContents, string fileDownloadName)
-        {
-            return ResumeFile(controller, fileContents, _mimeMapper.GetMimeFromPath(fileDownloadName), fileDownloadName, null);
-        }
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="fileContents">文件二进制流</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <returns></returns>
+    public static ResumeFileContentResult ResumeFile(this ControllerBase controller, byte[] fileContents, string fileDownloadName)
+    {
+        return ResumeFile(controller, fileContents, MimeMapper.GetMimeFromPath(fileDownloadName), fileDownloadName, null);
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="fileContents">文件二进制流</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <param name="etag">ETag</param>
-        /// <returns></returns>
-        public static ResumeFileContentResult ResumeFile(this ControllerBase controller, byte[] fileContents, string contentType, string fileDownloadName, string etag)
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="fileContents">文件二进制流</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <param name="etag">ETag</param>
+    /// <returns></returns>
+    public static ResumeFileContentResult ResumeFile(this ControllerBase controller, byte[] fileContents, string contentType, string fileDownloadName, string etag)
+    {
+        return new ResumeFileContentResult(fileContents, contentType, etag)
         {
-            return new ResumeFileContentResult(fileContents, contentType, etag)
-            {
-                FileDownloadName = fileDownloadName
-            };
-        }
+            FileDownloadName = fileDownloadName
+        };
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="fileStream">文件二进制流</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <returns></returns>
-        public static ResumeFileStreamResult ResumeFile(this ControllerBase controller, FileStream fileStream, string contentType, string fileDownloadName)
-        {
-            return ResumeFile(controller, fileStream, contentType, fileDownloadName, null);
-        }
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="fileStream">文件二进制流</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <returns></returns>
+    public static ResumeFileStreamResult ResumeFile(this ControllerBase controller, Stream fileStream, string contentType, string fileDownloadName)
+    {
+        return ResumeFile(controller, fileStream, contentType, fileDownloadName, null);
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="fileStream">文件二进制流</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <returns></returns>
-        public static ResumeFileStreamResult ResumeFile(this ControllerBase controller, FileStream fileStream, string fileDownloadName)
-        {
-            return ResumeFile(controller, fileStream, _mimeMapper.GetMimeFromPath(fileDownloadName), fileDownloadName, null);
-        }
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="fileStream">文件二进制流</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <returns></returns>
+    public static ResumeFileStreamResult ResumeFile(this ControllerBase controller, Stream fileStream, string fileDownloadName)
+    {
+        return ResumeFile(controller, fileStream, MimeMapper.GetMimeFromPath(fileDownloadName), fileDownloadName, null);
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="fileStream">文件二进制流</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <param name="etag">ETag</param>
-        /// <returns></returns>
-        public static ResumeFileStreamResult ResumeFile(this ControllerBase controller, FileStream fileStream, string contentType, string fileDownloadName, string etag)
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="fileStream">文件二进制流</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <param name="etag">ETag</param>
+    /// <returns></returns>
+    public static ResumeFileStreamResult ResumeFile(this ControllerBase controller, Stream fileStream, string contentType, string fileDownloadName, string etag)
+    {
+        return new ResumeFileStreamResult(fileStream, contentType, etag)
         {
-            return new ResumeFileStreamResult(fileStream, contentType, etag)
-            {
-                FileDownloadName = fileDownloadName
-            };
-        }
+            FileDownloadName = fileDownloadName
+        };
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="virtualPath">服务端本地文件的虚拟路径</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <returns></returns>
-        public static ResumeVirtualFileResult ResumeFile(this ControllerBase controller, string virtualPath, string contentType, string fileDownloadName)
-        {
-            return ResumeFile(controller, virtualPath, contentType, fileDownloadName, null);
-        }
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="virtualPath">服务端本地文件的虚拟路径</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <returns></returns>
+    public static ResumeVirtualFileResult ResumeFile(this ControllerBase controller, string virtualPath, string contentType, string fileDownloadName)
+    {
+        return ResumeFile(controller, virtualPath, contentType, fileDownloadName, null);
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="virtualPath">服务端本地文件的虚拟路径</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <returns></returns>
-        public static ResumeVirtualFileResult ResumeFile(this ControllerBase controller, string virtualPath, string fileDownloadName)
-        {
-            return ResumeFile(controller, virtualPath, _mimeMapper.GetMimeFromPath(virtualPath), fileDownloadName, null);
-        }
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="virtualPath">服务端本地文件的虚拟路径</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <returns></returns>
+    public static ResumeVirtualFileResult ResumeFile(this ControllerBase controller, string virtualPath, string fileDownloadName)
+    {
+        return ResumeFile(controller, virtualPath, MimeMapper.GetMimeFromPath(virtualPath), fileDownloadName, null);
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="virtualPath">服务端本地文件的虚拟路径</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <param name="etag">ETag</param>
-        /// <returns></returns>
-        public static ResumeVirtualFileResult ResumeFile(this ControllerBase controller, string virtualPath, string contentType, string fileDownloadName, string etag)
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="virtualPath">服务端本地文件的虚拟路径</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <param name="etag">ETag</param>
+    /// <returns></returns>
+    public static ResumeVirtualFileResult ResumeFile(this ControllerBase controller, string virtualPath, string contentType, string fileDownloadName, string etag)
+    {
+        return new ResumeVirtualFileResult(virtualPath, contentType, etag)
         {
-            return new ResumeVirtualFileResult(virtualPath, contentType, etag)
-            {
-                FileDownloadName = fileDownloadName
-            };
-        }
+            FileDownloadName = fileDownloadName
+        };
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="physicalPath">服务端本地文件的物理路径</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <returns></returns>
-        public static ResumePhysicalFileResult ResumePhysicalFile(this ControllerBase controller, string physicalPath, string contentType, string fileDownloadName)
-        {
-            return ResumePhysicalFile(controller, physicalPath, contentType, fileDownloadName, etag: null);
-        }
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="physicalPath">服务端本地文件的物理路径</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <returns></returns>
+    public static ResumePhysicalFileResult ResumePhysicalFile(this ControllerBase controller, string physicalPath, string contentType, string fileDownloadName)
+    {
+        return ResumePhysicalFile(controller, physicalPath, contentType, fileDownloadName, etag: null);
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="physicalPath">服务端本地文件的物理路径</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <returns></returns>
-        public static ResumePhysicalFileResult ResumePhysicalFile(this ControllerBase controller, string physicalPath, string fileDownloadName)
-        {
-            return ResumePhysicalFile(controller, physicalPath, _mimeMapper.GetMimeFromPath(physicalPath), fileDownloadName, etag: null);
-        }
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="physicalPath">服务端本地文件的物理路径</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <returns></returns>
+    public static ResumePhysicalFileResult ResumePhysicalFile(this ControllerBase controller, string physicalPath, string fileDownloadName)
+    {
+        return ResumePhysicalFile(controller, physicalPath, MimeMapper.GetMimeFromPath(physicalPath), fileDownloadName, etag: null);
+    }
 
-        /// <summary>
-        /// 可断点续传和多线程下载的FileResult
-        /// </summary>
-        /// <param name="controller"></param>
-        /// <param name="physicalPath">服务端本地文件的物理路径</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="fileDownloadName">下载的文件名</param>
-        /// <param name="etag">ETag</param>
-        /// <returns></returns>
-        public static ResumePhysicalFileResult ResumePhysicalFile(this ControllerBase controller, string physicalPath, string contentType, string fileDownloadName, string etag)
+    /// <summary>
+    /// 可断点续传和多线程下载的FileResult
+    /// </summary>
+    /// <param name="controller"></param>
+    /// <param name="physicalPath">服务端本地文件的物理路径</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="fileDownloadName">下载的文件名</param>
+    /// <param name="etag">ETag</param>
+    /// <returns></returns>
+    public static ResumePhysicalFileResult ResumePhysicalFile(this ControllerBase controller, string physicalPath, string contentType, string fileDownloadName, string etag)
+    {
+        return new ResumePhysicalFileResult(physicalPath, contentType, etag)
         {
-            return new ResumePhysicalFileResult(physicalPath, contentType, etag)
-            {
-                FileDownloadName = fileDownloadName
-            };
-        }
+            FileDownloadName = fileDownloadName
+        };
     }
 }

+ 13 - 14
Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/IResumeFileResult.cs

@@ -1,18 +1,17 @@
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
+
+/// <summary>
+/// 可断点续传的FileResult
+/// </summary>
+public interface IResumeFileResult
 {
     /// <summary>
-    /// 可断点续传的FileResult
+    /// 文件下载名
     /// </summary>
-    public interface IResumeFileResult
-    {
-        /// <summary>
-        /// 文件下载名
-        /// </summary>
-        string FileDownloadName { get; set; }
+    string FileDownloadName { get; set; }
 
-        /// <summary>
-        /// 给响应头的文件名
-        /// </summary>
-        string FileInlineName { get; set; }
-    }
-}
+    /// <summary>
+    /// 给响应头的文件名
+    /// </summary>
+    string FileInlineName { get; set; }
+}

+ 34 - 38
Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/ResumeFileContentResult.cs

@@ -1,52 +1,48 @@
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Net.Http.Headers;
-using System;
-using System.Threading.Tasks;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
+
+/// <summary>
+/// 基于Stream的ResumeFileContentResult
+/// </summary>
+public class ResumeFileContentResult : FileContentResult, IResumeFileResult
 {
     /// <summary>
-    /// 基于Stream的ResumeFileContentResult
+    /// 构造函数
     /// </summary>
-    public class ResumeFileContentResult : FileContentResult, IResumeFileResult
+    /// <param name="fileContents">文件二进制流</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="etag">ETag</param>
+    public ResumeFileContentResult(byte[] fileContents, string contentType, string etag = null) : this(fileContents, MediaTypeHeaderValue.Parse(contentType), !string.IsNullOrEmpty(etag) ? EntityTagHeaderValue.Parse(etag) : null)
     {
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="fileContents">文件二进制流</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="etag">ETag</param>
-        public ResumeFileContentResult(byte[] fileContents, string contentType, string etag = null) : this(fileContents, MediaTypeHeaderValue.Parse(contentType), !string.IsNullOrEmpty(etag) ? EntityTagHeaderValue.Parse(etag) : null)
-        {
-        }
+    }
 
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="fileContents">文件二进制流</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="etag">ETag</param>
-        public ResumeFileContentResult(byte[] fileContents, MediaTypeHeaderValue contentType, EntityTagHeaderValue etag = null) : base(fileContents, contentType)
-        {
-            EntityTag = etag;
-            EnableRangeProcessing = true;
-        }
+    /// <summary>
+    /// 构造函数
+    /// </summary>
+    /// <param name="fileContents">文件二进制流</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="etag">ETag</param>
+    public ResumeFileContentResult(byte[] fileContents, MediaTypeHeaderValue contentType, EntityTagHeaderValue etag = null) : base(fileContents, contentType)
+    {
+        EntityTag = etag;
+        EnableRangeProcessing = true;
+    }
 
-        /// <inheritdoc/>
-        public string FileInlineName { get; set; }
+    /// <inheritdoc/>
+    public string FileInlineName { get; set; }
 
-        /// <inheritdoc/>
-        public override Task ExecuteResultAsync(ActionContext context)
+    /// <inheritdoc/>
+    public override Task ExecuteResultAsync(ActionContext context)
+    {
+        if (context == null)
         {
-            if (context == null)
-            {
-                throw new ArgumentNullException(nameof(context));
-            }
-
-            var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ResumeFileContentResult>>();
-            return executor.ExecuteAsync(context, this);
+            throw new ArgumentNullException(nameof(context));
         }
+
+        var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ResumeFileContentResult>>();
+        return executor.ExecuteAsync(context, this);
     }
-}
+}

+ 34 - 39
Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/ResumeFileStreamResult.cs

@@ -1,53 +1,48 @@
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Net.Http.Headers;
-using System;
-using System.IO;
-using System.Threading.Tasks;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
+
+/// <summary>
+/// 基于Stream的ResumeFileStreamResult
+/// </summary>
+public class ResumeFileStreamResult : FileStreamResult, IResumeFileResult
 {
     /// <summary>
-    /// 基于Stream的ResumeFileStreamResult
+    /// 构造函数
     /// </summary>
-    public class ResumeFileStreamResult : FileStreamResult, IResumeFileResult
+    /// <param name="fileStream">文件流</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="etag">ETag</param>
+    public ResumeFileStreamResult(Stream fileStream, string contentType, string etag = null) : this(fileStream, MediaTypeHeaderValue.Parse(contentType), !string.IsNullOrEmpty(etag) ? EntityTagHeaderValue.Parse(etag) : null)
     {
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="fileStream">文件流</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="etag">ETag</param>
-        public ResumeFileStreamResult(FileStream fileStream, string contentType, string etag = null) : this(fileStream, MediaTypeHeaderValue.Parse(contentType), !string.IsNullOrEmpty(etag) ? EntityTagHeaderValue.Parse(etag) : null)
-        {
-        }
+    }
 
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="fileStream">文件流</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="etag">ETag</param>
-        public ResumeFileStreamResult(FileStream fileStream, MediaTypeHeaderValue contentType, EntityTagHeaderValue etag = null) : base(fileStream, contentType)
-        {
-            EntityTag = etag;
-            EnableRangeProcessing = true;
-        }
+    /// <summary>
+    /// 构造函数
+    /// </summary>
+    /// <param name="fileStream">文件流</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="etag">ETag</param>
+    public ResumeFileStreamResult(Stream fileStream, MediaTypeHeaderValue contentType, EntityTagHeaderValue etag = null) : base(fileStream, contentType)
+    {
+        EntityTag = etag;
+        EnableRangeProcessing = true;
+    }
 
-        /// <inheritdoc/>
-        public string FileInlineName { get; set; }
+    /// <inheritdoc/>
+    public string FileInlineName { get; set; }
 
-        /// <inheritdoc/>
-        public override Task ExecuteResultAsync(ActionContext context)
+    /// <inheritdoc/>
+    public override Task ExecuteResultAsync(ActionContext context)
+    {
+        if (context == null)
         {
-            if (context == null)
-            {
-                throw new ArgumentNullException(nameof(context));
-            }
-
-            var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ResumeFileStreamResult>>();
-            return executor.ExecuteAsync(context, this);
+            throw new ArgumentNullException(nameof(context));
         }
+
+        var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ResumeFileStreamResult>>();
+        return executor.ExecuteAsync(context, this);
     }
-}
+}

+ 33 - 37
Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/ResumePhysicalFileResult.cs

@@ -1,52 +1,48 @@
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Net.Http.Headers;
-using System;
-using System.Threading.Tasks;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
+
+/// <summary>
+/// 基于本地物理路径的ResumePhysicalFileResult
+/// </summary>
+public class ResumePhysicalFileResult : PhysicalFileResult, IResumeFileResult
 {
     /// <summary>
     /// 基于本地物理路径的ResumePhysicalFileResult
     /// </summary>
-    public class ResumePhysicalFileResult : PhysicalFileResult, IResumeFileResult
+    /// <param name="fileName">文件全路径</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="etag">ETag</param>
+    public ResumePhysicalFileResult(string fileName, string contentType, string etag = null) : this(fileName, MediaTypeHeaderValue.Parse(contentType), !string.IsNullOrEmpty(etag) ? EntityTagHeaderValue.Parse(etag) : null)
     {
-        /// <summary>
-        /// 基于本地物理路径的ResumePhysicalFileResult
-        /// </summary>
-        /// <param name="fileName">文件全路径</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="etag">ETag</param>
-        public ResumePhysicalFileResult(string fileName, string contentType, string etag = null) : this(fileName, MediaTypeHeaderValue.Parse(contentType), !string.IsNullOrEmpty(etag) ? EntityTagHeaderValue.Parse(etag) : null)
-        {
-        }
+    }
 
-        /// <summary>
-        /// 基于本地物理路径的ResumePhysicalFileResult
-        /// </summary>
-        /// <param name="fileName">文件全路径</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="etag">ETag</param>
-        public ResumePhysicalFileResult(string fileName, MediaTypeHeaderValue contentType, EntityTagHeaderValue etag = null) : base(fileName, contentType)
-        {
-            EntityTag = etag;
-            EnableRangeProcessing = true;
-        }
+    /// <summary>
+    /// 基于本地物理路径的ResumePhysicalFileResult
+    /// </summary>
+    /// <param name="fileName">文件全路径</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="etag">ETag</param>
+    public ResumePhysicalFileResult(string fileName, MediaTypeHeaderValue contentType, EntityTagHeaderValue etag = null) : base(fileName, contentType)
+    {
+        EntityTag = etag;
+        EnableRangeProcessing = true;
+    }
 
-        /// <inheritdoc/>
-        public string FileInlineName { get; set; }
+    /// <inheritdoc/>
+    public string FileInlineName { get; set; }
 
-        /// <inheritdoc/>
-        public override Task ExecuteResultAsync(ActionContext context)
+    /// <inheritdoc/>
+    public override Task ExecuteResultAsync(ActionContext context)
+    {
+        if (context == null)
         {
-            if (context == null)
-            {
-                throw new ArgumentNullException(nameof(context));
-            }
-
-            var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ResumePhysicalFileResult>>();
-            return executor.ExecuteAsync(context, this);
+            throw new ArgumentNullException(nameof(context));
         }
+
+        var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ResumePhysicalFileResult>>();
+        return executor.ExecuteAsync(context, this);
     }
-}
+}

+ 33 - 37
Masuit.Tools.AspNetCore/AspNetCore/ResumeFileResult/ResumeVirtualFileResult.cs

@@ -1,52 +1,48 @@
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Net.Http.Headers;
-using System;
-using System.Threading.Tasks;
 
-namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult
+namespace Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
+
+/// <summary>
+/// 基于服务器虚拟路径路径的ResumePhysicalFileResult
+/// </summary>
+public class ResumeVirtualFileResult : VirtualFileResult, IResumeFileResult
 {
     /// <summary>
     /// 基于服务器虚拟路径路径的ResumePhysicalFileResult
     /// </summary>
-    public class ResumeVirtualFileResult : VirtualFileResult, IResumeFileResult
+    /// <param name="fileName">文件全路径</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="etag">ETag</param>
+    public ResumeVirtualFileResult(string fileName, string contentType, string etag = null) : this(fileName, MediaTypeHeaderValue.Parse(contentType), !string.IsNullOrEmpty(etag) ? EntityTagHeaderValue.Parse(etag) : null)
     {
-        /// <summary>
-        /// 基于服务器虚拟路径路径的ResumePhysicalFileResult
-        /// </summary>
-        /// <param name="fileName">文件全路径</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="etag">ETag</param>
-        public ResumeVirtualFileResult(string fileName, string contentType, string etag = null) : this(fileName, MediaTypeHeaderValue.Parse(contentType), !string.IsNullOrEmpty(etag) ? EntityTagHeaderValue.Parse(etag) : null)
-        {
-        }
+    }
 
-        /// <summary>
-        /// 基于服务器虚拟路径路径的ResumePhysicalFileResult
-        /// </summary>
-        /// <param name="fileName">文件全路径</param>
-        /// <param name="contentType">Content-Type</param>
-        /// <param name="etag">ETag</param>
-        public ResumeVirtualFileResult(string fileName, MediaTypeHeaderValue contentType, EntityTagHeaderValue etag = null) : base(fileName, contentType)
-        {
-            EntityTag = etag;
-            EnableRangeProcessing = true;
-        }
+    /// <summary>
+    /// 基于服务器虚拟路径路径的ResumePhysicalFileResult
+    /// </summary>
+    /// <param name="fileName">文件全路径</param>
+    /// <param name="contentType">Content-Type</param>
+    /// <param name="etag">ETag</param>
+    public ResumeVirtualFileResult(string fileName, MediaTypeHeaderValue contentType, EntityTagHeaderValue etag = null) : base(fileName, contentType)
+    {
+        EntityTag = etag;
+        EnableRangeProcessing = true;
+    }
 
-        /// <inheritdoc/>
-        public string FileInlineName { get; set; }
+    /// <inheritdoc/>
+    public string FileInlineName { get; set; }
 
-        /// <inheritdoc/>
-        public override Task ExecuteResultAsync(ActionContext context)
+    /// <inheritdoc/>
+    public override Task ExecuteResultAsync(ActionContext context)
+    {
+        if (context == null)
         {
-            if (context == null)
-            {
-                throw new ArgumentNullException(nameof(context));
-            }
-
-            var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ResumeVirtualFileResult>>();
-            return executor.ExecuteAsync(context, this);
+            throw new ArgumentNullException(nameof(context));
         }
+
+        var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ResumeVirtualFileResult>>();
+        return executor.ExecuteAsync(context, this);
     }
-}
+}

+ 1 - 6
Masuit.Tools.AspNetCore/AspNetCore/ServiceCollectionExtensions.cs

@@ -1,13 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Masuit.Tools.AspNetCore.ResumeFileResults.Executor;
+using Masuit.Tools.AspNetCore.ResumeFileResults.Executor;
 using Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
 using Masuit.Tools.Files;
 using Microsoft.AspNetCore.Mvc.Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.DependencyInjection.Extensions;
-using Microsoft.Extensions.Hosting;
 using System.Reflection;
 
 namespace Masuit.Tools.Core.AspNetCore;

+ 1 - 1
Masuit.Tools.AspNetCore/AspNetCore/UpdateIgnoreAttribute.cs

@@ -6,4 +6,4 @@
 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
 public sealed class UpdateIgnoreAttribute : Attribute
 {
-}
+}

+ 1 - 2
Masuit.Tools.AspNetCore/Extensions/DisableFormValueModelBindingAttribute.cs

@@ -1,5 +1,4 @@
-using System;
-using Microsoft.AspNetCore.Mvc.Filters;
+using Microsoft.AspNetCore.Mvc.Filters;
 using Microsoft.AspNetCore.Mvc.ModelBinding;
 
 namespace Masuit.Tools.AspNetCore.Extensions;

+ 2 - 3
Masuit.Tools.AspNetCore/Extensions/DistributedCacheExt.cs

@@ -1,8 +1,7 @@
-using System;
-using System.Text;
-using Masuit.Tools.Systems;
+using Masuit.Tools.Systems;
 using Microsoft.Extensions.Caching.Distributed;
 using Newtonsoft.Json;
+using System.Text;
 
 namespace Masuit.Tools.AspNetCore.Extensions;
 

+ 0 - 3
Masuit.Tools.AspNetCore/Extensions/IMultipartRequestService.cs

@@ -1,8 +1,5 @@
 using Microsoft.AspNetCore.WebUtilities;
 using Microsoft.Extensions.Primitives;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
 
 namespace Masuit.Tools.AspNetCore.Extensions;
 

+ 1 - 8
Masuit.Tools.AspNetCore/Extensions/MultipartRequestService.cs

@@ -1,15 +1,9 @@
 using Masuit.Tools.Core.AspNetCore;
 using Masuit.Tools.Systems;
 using Microsoft.AspNetCore.WebUtilities;
-using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Primitives;
 using Microsoft.Net.Http.Headers;
-using System;
-using System.Collections.Generic;
-using System.IO;
 using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
 
 namespace Masuit.Tools.AspNetCore.Extensions;
 
@@ -21,8 +15,7 @@ public class MultipartRequestService : IMultipartRequestService
         var formAccumulator = new KeyValueAccumulator();
         var file = Array.Empty<byte>();
 
-        MultipartSection section;
-        while ((section = await reader.ReadNextSectionAsync(cancellationToken)) != null)
+        while (await reader.ReadNextSectionAsync(cancellationToken) is { } section)
         {
             if (!ContentDispositionHeaderValue.TryParse(section.ContentDisposition, out var contentDisposition))
             {

+ 2 - 4
Masuit.Tools.AspNetCore/Extensions/QueryWithNoLockDbCommandInterceptor.cs

@@ -1,8 +1,6 @@
-using System.Data.Common;
+using Microsoft.EntityFrameworkCore.Diagnostics;
+using System.Data.Common;
 using System.Text.RegularExpressions;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.EntityFrameworkCore.Diagnostics;
 
 namespace Masuit.Tools.Core;
 

+ 1 - 2
Masuit.Tools.AspNetCore/Extensions/ServiceCollectionExt.cs

@@ -1,5 +1,4 @@
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.DependencyInjection.Extensions;
+using Microsoft.Extensions.DependencyInjection.Extensions;
 
 namespace Masuit.Tools.AspNetCore.Extensions;
 

+ 0 - 1
Masuit.Tools.AspNetCore/Extensions/ViewDataDictionaryExt.cs

@@ -1,5 +1,4 @@
 using Microsoft.AspNetCore.Mvc.ViewFeatures;
-using System;
 
 namespace Masuit.Tools.AspNetCore.Extensions;
 

+ 1 - 4
Masuit.Tools.AspNetCore/ModelBinder/BodyOrDefaultModelBinder.cs

@@ -1,10 +1,7 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
-using System;
 using System.Text;
-using System.Threading.Tasks;
 
 namespace Masuit.Tools.AspNetCore.ModelBinder;
 

+ 1 - 3
Masuit.Tools.AspNetCore/ModelBinder/BodyOrDefaultModelBinderProviderSetup.cs

@@ -1,6 +1,4 @@
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
 using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
 
 #if NET5_0_OR_GREATER

+ 1 - 2
Masuit.Tools.AspNetCore/ModelBinder/FromBodyOrDefaultAttribute.cs

@@ -1,5 +1,4 @@
-using System;
-using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
 
 namespace Masuit.Tools.AspNetCore.ModelBinder;
 

+ 30 - 32
Masuit.Tools.AspNetCore/Net/WebExtension.cs

@@ -1,45 +1,43 @@
 using FastExpressionCompiler;
-using Microsoft.AspNetCore.Http;
 using Newtonsoft.Json;
 using System.Linq.Expressions;
 
-namespace Masuit.Tools.Core.Net
+namespace Masuit.Tools.Core.Net;
+
+/// <summary>
+/// Web操作扩展
+/// </summary>
+public static class WebExtension
 {
     /// <summary>
-    /// Web操作扩展
+    /// 写Session
     /// </summary>
-    public static class WebExtension
+    /// <param name="session"></param>
+    /// <param name="key">键</param>
+    /// <param name="value">值</param>
+    public static void Set(this ISession session, string key, object value)
     {
-        /// <summary>
-        /// 写Session
-        /// </summary>
-        /// <param name="session"></param>
-        /// <param name="key">键</param>
-        /// <param name="value">值</param>
-        public static void Set(this ISession session, string key, object value)
-        {
-            session.SetString(key, value.ToJsonString());
-        }
+        session.SetString(key, value.ToJsonString());
+    }
 
-        /// <summary>
-        /// 获取Session
-        /// </summary>
-        /// <typeparam name="T">对象</typeparam>
-        /// <param name="session"></param>
-        /// <param name="key">键</param>
-        /// <returns>对象</returns>
-        public static T Get<T>(this ISession session, string key)
+    /// <summary>
+    /// 获取Session
+    /// </summary>
+    /// <typeparam name="T">对象</typeparam>
+    /// <param name="session"></param>
+    /// <param name="key">键</param>
+    /// <returns>对象</returns>
+    public static T Get<T>(this ISession session, string key)
+    {
+        string value = session.GetString(key);
+        if (string.IsNullOrEmpty(value))
         {
-            string value = session.GetString(key);
-            if (string.IsNullOrEmpty(value))
+            return typeof(T).Namespace switch
             {
-                return typeof(T).Namespace switch
-                {
-                    "System.Collections.Generic" => (T)(Expression.Lambda(Expression.New(typeof(T))).CompileFast().DynamicInvoke()),
-                    _ => default
-                };
-            }
-            return JsonConvert.DeserializeObject<T>(value);
+                "System.Collections.Generic" => (T)(Expression.Lambda(Expression.New(typeof(T))).CompileFast().DynamicInvoke()),
+                _ => default
+            };
         }
+        return JsonConvert.DeserializeObject<T>(value);
     }
-}
+}