From 00a131fe85644af23df4ecfa0130e6b5c970b705 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Tue, 21 Dec 2021 04:16:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20BootstrapDynamicComponent=20?= =?UTF-8?q?=E9=9D=99=E6=80=81=E6=96=B9=E6=B3=95=E5=8F=82=E6=95=B0=E5=8F=AF?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 4 +++- .../Utils/BootstrapDynamicComponent.cs | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.editorconfig b/.editorconfig index 269c8e972..d0722647b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -91,7 +91,7 @@ csharp_style_var_when_type_is_apparent = true:silent csharp_style_var_elsewhere = true:silent csharp_prefer_static_local_function= true:silent # Expression-bodied members -csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_methods =true:silent csharp_style_expression_bodied_constructors = false:silent csharp_style_expression_bodied_operators = false:silent csharp_style_expression_bodied_properties = true:silent @@ -150,3 +150,5 @@ visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public [*.cs] # Add file header file_header_template = Copyright (c) Argo Zhang (argo@163.com). All rights reserved.\nLicensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nWebsite: https://www.blazor.zone or https://argozhang.github.io/ +csharp_style_namespace_declarations=file_scoped:suggestion +csharp_style_expression_bodied_local_functions=true:silent diff --git a/src/BootstrapBlazor/Utils/BootstrapDynamicComponent.cs b/src/BootstrapBlazor/Utils/BootstrapDynamicComponent.cs index af46fb494..24584d5bc 100644 --- a/src/BootstrapBlazor/Utils/BootstrapDynamicComponent.cs +++ b/src/BootstrapBlazor/Utils/BootstrapDynamicComponent.cs @@ -16,7 +16,7 @@ namespace BootstrapBlazor.Components /// /// 获得/设置 组件参数集合 /// - private IDictionary Parameters { get; set; } + private IDictionary? Parameters { get; set; } /// /// 获得/设置 组件类型 @@ -28,7 +28,7 @@ namespace BootstrapBlazor.Components /// /// /// TCom 组件所需要的参数集合 - public BootstrapDynamicComponent(Type componentType, IDictionary parameters) + public BootstrapDynamicComponent(Type componentType, IDictionary? parameters = null) { ComponentType = componentType; Parameters = parameters; @@ -40,7 +40,7 @@ namespace BootstrapBlazor.Components /// /// TCom 组件所需要的参数集合 /// - public static BootstrapDynamicComponent CreateComponent(IDictionary parameters) where TCom : IComponent => new(typeof(TCom), parameters); + public static BootstrapDynamicComponent CreateComponent(IDictionary? parameters = null) where TCom : IComponent => new(typeof(TCom), parameters); /// /// 创建自定义组件方法 @@ -57,9 +57,12 @@ namespace BootstrapBlazor.Components { var index = 0; builder.OpenComponent(index++, ComponentType); - foreach (var p in Parameters) + if (Parameters != null) { - builder.AddAttribute(index++, p.Key, p.Value); + foreach (var p in Parameters) + { + builder.AddAttribute(index++, p.Key, p.Value); + } } builder.CloseComponent(); }; -- Gitee From 0fb25954c4ec1cae17a09478f44c4a2962d6e4ee Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Tue, 21 Dec 2021 04:27:39 +0800 Subject: [PATCH 2/2] chore: bump version to beta08 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 04c596914..c042c63e1 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 6.1.1-beta06 + 6.1.1-beta08 -- Gitee