Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DockViewV2): update Renderer parameter to enum data type #4203

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
end_of_line = crlf
dotnet_style_prefer_collection_expression = true:suggestion
dotnet_style_prefer_collection_expression = when_types_exactly_match:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_namespace_match_folder = false:suggestion
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
dotnet_code_quality_unused_parameters = all:suggestion
Expand Down Expand Up @@ -245,3 +245,4 @@ csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_prefer_static_anonymous_function = true:suggestion
2 changes: 1 addition & 1 deletion src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<PackageReference Include="BootstrapBlazor.CherryMarkdown" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.CodeEditor" Version="8.0.2" />
<PackageReference Include="BootstrapBlazor.Dock" Version="8.1.7" />
<PackageReference Include="BootstrapBlazor.DockView" Version="8.1.2" />
<PackageReference Include="BootstrapBlazor.DockView" Version="8.1.3" />
<PackageReference Include="BootstrapBlazor.DriverJs" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.ElementIcon" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.FileViewer" Version="8.0.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>8.1.2</Version>
<Version>8.1.3</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class DockViewConfig
/// <summary>
/// 获得/设置 客户端渲染模式 默认 null 客户端默认使用 always onlyWhenVisible 值
/// </summary>
public string? Renderer { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public DockViewRenderMode Renderer { get; set; }

/// <summary>
/// 获得/设置 标签页可见状态改变事件回调
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BootstrapBlazor.Components;
/// <summary>
/// DockContent 类型
/// </summary>
[JsonConverter(typeof(DockViewTypeConverter))]
[JsonConverter(typeof(DockViewTypeConverter<DockViewContentType>))]
public enum DockViewContentType
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using System.ComponentModel;
using System.Text.Json.Serialization;

namespace BootstrapBlazor.Components;

/// <summary>
/// DockViewRenderMode 渲染模式枚举类型
/// </summary>
[JsonConverter(typeof(DockViewTypeConverter<DockViewRenderMode>))]
public enum DockViewRenderMode
{
/// <summary>
/// 可见时渲染
/// </summary>
[Description("onlyWhenVisible")]
OnlyWhenVisible,

/// <summary>
/// 始终渲染
/// </summary>
[Description("always")]
Always
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public partial class DockViewV2
public bool ShowFloat { get; set; } = true;

/// <summary>
/// 获得/设置 客户端渲染模式 默认 null 客户端默认使用 always onlyWhenVisible 值
/// 获得/设置 客户端渲染模式 默认 <see cref="DockViewRenderMode.OnlyWhenVisible"/> 客户端默认使用 always onlyWhenVisible 值
/// </summary>
[Parameter]
public string? Renderer { get; set; }
public DockViewRenderMode Renderer { get; set; }

/// <summary>
/// 获得/设置 锁定状态回调此方法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BootstrapBlazor.Components;
/// <summary>
/// DockType 转换器
/// </summary>
class DockViewTypeConverter : JsonConverter<DockViewContentType>
class DockViewTypeConverter<T> : JsonConverter<T>
{
/// <summary>
/// <inheritdoc/>
Expand All @@ -20,7 +20,7 @@ class DockViewTypeConverter : JsonConverter<DockViewContentType>
/// <param name="options"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public override DockViewContentType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
Expand All @@ -31,8 +31,8 @@ public override DockViewContentType Read(ref Utf8JsonReader reader, Type typeToC
/// <param name="writer"></param>
/// <param name="value"></param>
/// <param name="options"></param>
public override void Write(Utf8JsonWriter writer, DockViewContentType value, JsonSerializerOptions options)
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
writer.WriteStringValue(value.ToDescriptionString());
writer.WriteStringValue(typeof(T).ToDescriptionString(value?.ToString()));
}
}