Skip to content

Commit 59728fc

Browse files
committed
Merge branch 'main' into doc-home
2 parents 6dc7d0b + 94ff90c commit 59728fc

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

src/BootstrapBlazor.Server/Components/Pages/Index.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</span>
1414
</a>
1515
<div class="bb-logo d-sm-block mx-auto my-5">
16+
<div class="holder"></div>
1617
<img src="./favicon.png" alt="bootstrap-blazor">
1718
</div>
1819
<h1 class="mb-3 fw-semibold">@Localizer["Title"]</h1>

src/BootstrapBlazor.Server/Components/Pages/Index.razor.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
border-radius: 30px;
3939
}
4040

41+
.bd-masthead .bb-logo .holder {
42+
background-color: var(--bb-primary-color);
43+
}
44+
45+
.bd-masthead .bb-logo .holder,
4146
.bd-masthead .bb-logo img {
4247
width: calc(100% - 2 * var(--bb-btn-space));
4348
height: calc(100% - 2 * var(--bb-btn-space));

src/BootstrapBlazor/Extensions/ObjectExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ internal static void Clone<TModel>(this TModel source, TModel item)
246246
/// <returns>An instance of the specified type with initialized properties.</returns>
247247
public static TItem? CreateInstance<TItem>(bool isAutoInitializeModelProperty = false)
248248
{
249+
if(typeof(TItem).IsInterface)
250+
{
251+
return default;
252+
}
253+
249254
var instance = Activator.CreateInstance<TItem>();
250255
if (isAutoInitializeModelProperty)
251256
{

test/UnitTest/Extensions/ObjectExtensionsTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,14 @@ public void CreateInstance_Ok()
315315
var instance = ObjectExtensions.CreateInstance<MockComplexObject>(false);
316316
Assert.NotNull(instance);
317317
Assert.Null(instance.Test);
318+
319+
// 接口类型不报错
320+
Assert.Null(ObjectExtensions.CreateInstance<MockInterface>(true));
321+
}
322+
323+
private interface MockInterface
324+
{
325+
string? Name { get; set; }
318326
}
319327

320328
private class MockComplexObject

0 commit comments

Comments
 (0)