/// <summary> /// 添加全局命令筛选器 /// </summary> /// <param name="commandOptions">命令选项</param> /// <param name="commandFilterType">命令筛选器类型</param> public static void AddGlobalCommandFilter(this CommandOptions commandOptions, Type commandFilterType) { if (!typeof(CommandFilterBaseAttribute).IsAssignableFrom(commandFilterType)) { throw new Exception("The command filter type must inherit CommandFilterBaseAttribute."); } commandOptions.AddGlobalCommandFilterType(commandFilterType); }
/// <summary> /// 添加全局命令筛选器 /// </summary> /// <typeparam name="TCommandFilter">命令筛选器</typeparam> /// <param name="commandOptions">命令选项</param> public static void AddGlobalCommandFilter <TCommandFilter>(this CommandOptions commandOptions) where TCommandFilter : CommandFilterBaseAttribute { commandOptions.AddGlobalCommandFilterType(typeof(TCommandFilter)); }