diff --git a/src/BootstrapBlazor.Server/Components/Samples/Table/TablesDynamic.razor b/src/BootstrapBlazor.Server/Components/Samples/Table/TablesDynamic.razor index 3e4eff4fd47..136f9b7f60b 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Table/TablesDynamic.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/Table/TablesDynamic.razor @@ -47,5 +47,3 @@ - - diff --git a/src/BootstrapBlazor.Server/Components/Samples/Table/TablesDynamic.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Table/TablesDynamic.razor.cs index 44709f13f11..e284d952258 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Table/TablesDynamic.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Table/TablesDynamic.razor.cs @@ -51,25 +51,25 @@ private void CreateContext() { context.AddRequiredAttribute(nameof(Foo.DateTime)); // 使用 AutoGenerateColumnAttribute 设置显示名称示例 - context.AddAutoGenerateColumnAttribute(nameof(Foo.DateTime), new KeyValuePair[] { new(nameof(AutoGenerateColumnAttribute.Text), Localizer[nameof(Foo.DateTime)].Value) }); + context.AddAutoGenerateColumnAttribute(nameof(Foo.DateTime), new KeyValuePair[] { new(nameof(AutoGenerateColumnAttribute.Text), LocalizerFoo[nameof(Foo.DateTime)].Value) }); } else if (propertyName == nameof(Foo.Name)) { - context.AddRequiredAttribute(nameof(Foo.Name), Localizer["Name.Required"]); + context.AddRequiredAttribute(nameof(Foo.Name), LocalizerFoo["Name.Required"]); // 使用 Text 设置显示名称示例 - col.Text = Localizer[nameof(Foo.Name)]; + col.Text = LocalizerFoo[nameof(Foo.Name)]; } else if (propertyName == nameof(Foo.Count)) { context.AddRequiredAttribute(nameof(Foo.Count)); // 使用 DisplayNameAttribute 设置显示名称示例 - context.AddDisplayNameAttribute(nameof(Foo.Count), Localizer[nameof(Foo.Count)].Value); + context.AddDisplayNameAttribute(nameof(Foo.Count), LocalizerFoo[nameof(Foo.Count)].Value); } else if (propertyName == nameof(Foo.Complete)) { col.Filterable = true; // 使用 DisplayAttribute 设置显示名称示例 - context.AddDisplayAttribute(nameof(Foo.Complete), new KeyValuePair[] { new(nameof(DisplayAttribute.Name), Localizer[nameof(Foo.Complete)].Value) }); + context.AddDisplayAttribute(nameof(Foo.Complete), new KeyValuePair[] { new(nameof(DisplayAttribute.Name), LocalizerFoo[nameof(Foo.Complete)].Value) }); } else if (propertyName == nameof(Foo.Id)) { diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 417a370ca4e..7ed5f9ec485 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 9.11.3-beta06 + 9.11.4 diff --git a/src/BootstrapBlazor/Dynamic/DataTableDynamicContext.cs b/src/BootstrapBlazor/Dynamic/DataTableDynamicContext.cs index ec98af44d11..4d1df8a63af 100644 --- a/src/BootstrapBlazor/Dynamic/DataTableDynamicContext.cs +++ b/src/BootstrapBlazor/Dynamic/DataTableDynamicContext.cs @@ -164,7 +164,7 @@ private List InternalGetColumns() var ret = new List(); foreach (DataColumn col in DataTable.Columns) { - ret.Add(new InternalTableColumn(col.ColumnName, col.DataType, col.Caption)); + ret.Add(new InternalTableColumn(col.ColumnName, col.DataType)); } return ret; } diff --git a/src/BootstrapBlazor/Dynamic/DynamicObjectContext.cs b/src/BootstrapBlazor/Dynamic/DynamicObjectContext.cs index 881b46a34b7..0c53f21347e 100644 --- a/src/BootstrapBlazor/Dynamic/DynamicObjectContext.cs +++ b/src/BootstrapBlazor/Dynamic/DynamicObjectContext.cs @@ -45,13 +45,14 @@ public void AddAttribute(string columnName, Type attributeType, Type[] types, ob var attr = attributeType.GetConstructor(types); if (attr != null) { - var cab = new CustomAttributeBuilder(attr, constructorArgs, namedProperties: propertyInfos ?? [], propertyValues: propertyValues ?? []); - CustomerAttributeBuilderCache.AddOrUpdate(columnName, key => [cab], (key, builders) => + CustomerAttributeBuilderCache.AddOrUpdate(columnName, key => [CreateCustomAttributeBuilder()], (key, builders) => { - builders.Add(cab); + builders.Add(CreateCustomAttributeBuilder()); return builders; }); } + + CustomAttributeBuilder CreateCustomAttributeBuilder() => new(attr, constructorArgs, propertyInfos ?? [], propertyValues ?? []); } /// diff --git a/src/BootstrapBlazor/Extensions/DynamicObjectContextExtensions.cs b/src/BootstrapBlazor/Extensions/DynamicObjectContextExtensions.cs index 3cfa3f88a38..61c30de3589 100644 --- a/src/BootstrapBlazor/Extensions/DynamicObjectContextExtensions.cs +++ b/src/BootstrapBlazor/Extensions/DynamicObjectContextExtensions.cs @@ -67,7 +67,7 @@ public static void AddMultipleParameterAttribute(this DynamicObjectC propertyValues.Add(kv.Value); } } - context.AddAttribute(columnName, type, Type.EmptyTypes, Array.Empty(), propertyInfos.ToArray(), propertyValues.ToArray()); + context.AddAttribute(columnName, type, Type.EmptyTypes, [], [.. propertyInfos], [.. propertyValues]); } /// diff --git a/src/BootstrapBlazor/Utils/EmitHelper.cs b/src/BootstrapBlazor/Utils/EmitHelper.cs index 31498980d82..658aee95376 100644 --- a/src/BootstrapBlazor/Utils/EmitHelper.cs +++ b/src/BootstrapBlazor/Utils/EmitHelper.cs @@ -67,7 +67,7 @@ private static void CreateProperty(this TypeBuilder typeBuilder, string property propertyId.SetGetMethod(methodGetField); propertyId.SetSetMethod(methodSetField); - foreach (var cab in attributeBuilds ?? Enumerable.Empty()) + foreach (var cab in attributeBuilds ?? []) { propertyId.SetCustomAttribute(cab); }