From 6a63035889e23fa0cf34a6d34057ecd0d847f440 Mon Sep 17 00:00:00 2001 From: FalconFly <12919280+falconfly@user.noreply.gitee.com> Date: Tue, 16 Apr 2024 10:59:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=92=8C=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/IServiceCollectionExtend.cs | 5 +++-- .../Service/PluginExecAddServicesException.cs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Falcon.SugarApi/Plugin/Service/PluginExecAddServicesException.cs diff --git a/Falcon.SugarApi/Plugin/Service/IServiceCollectionExtend.cs b/Falcon.SugarApi/Plugin/Service/IServiceCollectionExtend.cs index c34b6f4..b20cf3e 100644 --- a/Falcon.SugarApi/Plugin/Service/IServiceCollectionExtend.cs +++ b/Falcon.SugarApi/Plugin/Service/IServiceCollectionExtend.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using System; -using System.Collections.Generic; using System.IO; using System.Reflection; @@ -25,6 +24,7 @@ namespace Falcon.SugarApi.Plugin.Service /// 服务集合 /// 应用程序配置 /// 插件名称数组 + /// /// 服务集合 public static IServiceCollection AddPluginService(this IServiceCollection services,IConfiguration config,params string[] pluginNames) { var name = typeof(IServicePlugin).FullName; @@ -63,6 +63,7 @@ namespace Falcon.SugarApi.Plugin.Service /// 服务集合 /// 应用程序配置 /// 插件程序集数组 + /// /// 服务集合 public static IServiceCollection AddPluginService(this IServiceCollection services,IConfiguration config,params Assembly[] plugins) { var name = typeof(IServicePlugin).FullName; @@ -86,7 +87,7 @@ namespace Falcon.SugarApi.Plugin.Service obj.AddServices(services,config); } catch(Exception ex) { - throw new Exception($"调用插件{type.FullName}.IServicePlugin.AddServices]方法时发生异常。",ex); + throw new PluginExecAddServicesException(type,ex); } } } diff --git a/Falcon.SugarApi/Plugin/Service/PluginExecAddServicesException.cs b/Falcon.SugarApi/Plugin/Service/PluginExecAddServicesException.cs new file mode 100644 index 0000000..d751eef --- /dev/null +++ b/Falcon.SugarApi/Plugin/Service/PluginExecAddServicesException.cs @@ -0,0 +1,19 @@ +using System; + +namespace Falcon.SugarApi.Plugin.Service +{ + /// + /// 插件执行AddServices方法时发生错误 + /// + public class PluginExecAddServicesException:Exception + { + /// + /// 通过插件类型和异常类型引发异常 + /// + /// 插件注册类型 + /// 已发的异常 + public PluginExecAddServicesException(Type type,Exception innExecption) + : base($"调用插件{type.FullName}.IServicePlugin.AddServices]方法时发生异常。",innExecption) { + } + } +}