Skip to content

Commit 8be51f2

Browse files
committed
refactor: 增加二维码类型
1 parent 0d9f89f commit 8be51f2

File tree

4 files changed

+138
-0
lines changed

4 files changed

+138
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
namespace BootstrapBlazor.Server.Components.Samples.Tutorials;
7+
8+
/// <summary>
9+
/// EmailContent
10+
/// </summary>
11+
public class EmailContent
12+
{
13+
/// <summary>
14+
/// Gets or sets Email
15+
/// </summary>
16+
[Required]
17+
public string? Email { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets Subject
21+
/// </summary>
22+
[Required]
23+
public string? Subject { get; set; }
24+
25+
/// <summary>
26+
/// Gets or sets Message
27+
/// </summary>
28+
[Required]
29+
[AutoGenerateColumn(Rows = 3)]
30+
public string? Message { get; set; }
31+
32+
/// <summary>
33+
/// <inheritdoc/>
34+
/// </summary>
35+
/// <returns></returns>
36+
public override string ToString()
37+
{
38+
return $"mailto:{Email}?subject={Uri.EscapeDataString(Subject ?? "")}&body={Uri.EscapeDataString(Message ?? "")}";
39+
}
40+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
namespace BootstrapBlazor.Server.Components.Samples.Tutorials;
7+
8+
/// <summary>
9+
/// TextContent
10+
/// </summary>
11+
public class TextContent
12+
{
13+
/// <summary>
14+
/// Gets or sets the content.
15+
/// </summary>
16+
[Required]
17+
public string? Content { get; set; }
18+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 System.ComponentModel;
7+
8+
namespace BootstrapBlazor.Server.Components.Samples.Tutorials;
9+
10+
/// <summary>
11+
/// WiFiAuthentication enum
12+
/// </summary>
13+
public enum WiFiAuthentication
14+
{
15+
/// <summary>
16+
///
17+
/// </summary>
18+
[Description("None")]
19+
None,
20+
21+
/// <summary>
22+
///
23+
/// </summary>
24+
[Description("WEP")]
25+
WEP,
26+
27+
/// <summary>
28+
///
29+
/// </summary>
30+
[Description("WPA")]
31+
WPA
32+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
namespace BootstrapBlazor.Server.Components.Samples.Tutorials;
7+
8+
/// <summary>
9+
/// WiFi content class
10+
/// </summary>
11+
public class WiFiContent
12+
{
13+
/// <summary>
14+
/// Gets or sets the authentication type.
15+
/// </summary>
16+
public WiFiAuthentication Authentication { get; set; } = WiFiAuthentication.WPA;
17+
18+
/// <summary>
19+
/// Gets or sets the SSID.
20+
/// </summary>
21+
[Required]
22+
public string? SSID { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the password.
26+
/// </summary>
27+
[Required]
28+
public string? Password { get; set; }
29+
30+
/// <summary>
31+
/// <inheritdoc/>
32+
/// </summary>
33+
/// <returns></returns>
34+
public override string ToString()
35+
{
36+
return $"WIFI:S:{EscapeInput(SSID ?? "")};T:{Authentication};P:{Password};;";
37+
}
38+
39+
private static string EscapeInput(string content)
40+
{
41+
char[] array = ['\\', ';', ',', ':'];
42+
foreach (char c in array)
43+
{
44+
content = content.Replace(c.ToString(), "\\" + c);
45+
}
46+
return content;
47+
}
48+
}

0 commit comments

Comments
 (0)