Skip to content

Commit 5afb43a

Browse files
committed
feat: 增加 DropdownDivider 组件
1 parent 7eba918 commit 5afb43a

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
using Microsoft.AspNetCore.Components.Rendering;
7+
8+
namespace BootstrapBlazor.Components;
9+
10+
/// <summary>
11+
/// DropdownDivider 组件
12+
/// </summary>
13+
public class DropdownDivider : Divider, IDropdownItem, IDisposable
14+
{
15+
[CascadingParameter]
16+
[NotNull]
17+
private List<IDropdownItem>? Items { get; set; }
18+
19+
/// <summary>
20+
/// <inheritdoc/>
21+
/// </summary>
22+
protected override void OnInitialized()
23+
{
24+
base.OnInitialized();
25+
26+
Items.Add(this);
27+
}
28+
29+
/// <summary>
30+
/// <inheritdoc/>
31+
/// </summary>
32+
/// <param name="builder"></param>
33+
protected override void BuildRenderTree(RenderTreeBuilder builder) { }
34+
35+
private bool disposedValue;
36+
37+
/// <summary>
38+
/// 释放资源方法
39+
/// </summary>
40+
/// <param name="disposing"></param>
41+
protected virtual void Dispose(bool disposing)
42+
{
43+
if (!disposedValue)
44+
{
45+
if (disposing)
46+
{
47+
Items.Remove(this);
48+
}
49+
disposedValue = true;
50+
}
51+
}
52+
53+
/// <summary>
54+
/// <inheritdoc/>
55+
/// </summary>
56+
public void Dispose()
57+
{
58+
Dispose(true);
59+
GC.SuppressFinalize(this);
60+
}
61+
}

src/BootstrapBlazor/Components/Dropdown/DropdownDivider.razor

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)