diff --git a/src/BootstrapBlazor.Server/Components/Samples/Ajaxs.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Ajaxs.razor.cs index 9913abca239..683a41bb19c 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Ajaxs.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Ajaxs.razor.cs @@ -63,11 +63,6 @@ class User private Task Goto() => AjaxService.Goto("/introduction"); private Task GotoSelf() => AjaxService.Goto("/ajax"); - - /// - /// 获得属性方法 - /// - /// private List GetMethods() => [ new() diff --git a/src/BootstrapBlazor.Server/Components/Samples/CheckboxLists.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/CheckboxLists.razor.cs index 5ccf0f829f6..f5bb5b45442 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/CheckboxLists.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/CheckboxLists.razor.cs @@ -18,7 +18,6 @@ public partial class CheckboxLists EnumEducation.Middle, EnumEducation.Primary }; - [NotNull] private IEnumerable? Items1 { get; set; } diff --git a/src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor.cs index b17b152930b..e79834850f0 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor.cs @@ -13,7 +13,6 @@ public partial class EmbedPdfs private EmbedPDFTheme _theme = EmbedPDFTheme.System; private EmbedPDFScrollStrategy _strategy = EmbedPDFScrollStrategy.Vertical; private string _url = "./samples/sample.pdf"; - private string _streamFileName = ""; private string _language = ""; private List _languages = new List() { diff --git a/src/BootstrapBlazor.Server/Components/Samples/FlipClocks.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/FlipClocks.razor.cs index 226823894d3..0becafe9fb7 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/FlipClocks.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/FlipClocks.razor.cs @@ -34,7 +34,6 @@ public partial class FlipClocks private string CardGroupMarginValueString => $"{CardGroupMarginValue}px"; - private bool _isCompleted; private bool _showYear = false; private bool _showMonth = false; diff --git a/src/BootstrapBlazor.Server/Components/Samples/Translators.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Translators.razor.cs index 6181cc431f9..2000aecfe70 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Translators.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Translators.razor.cs @@ -48,11 +48,6 @@ private static string FormatResult(TranslationText translation) var culture = new CultureInfo(translation.TargetLanguage); return $"{culture.NativeName}: {translation.Text}"; } - - /// - /// 获得属性方法 - /// - /// protected MethodItem[] GetMethods() => [ new() diff --git a/src/BootstrapBlazor.Server/Data/AttributeItem.cs b/src/BootstrapBlazor.Server/Data/AttributeItem.cs index aa5e44fc78b..4d8af99c410 100644 --- a/src/BootstrapBlazor.Server/Data/AttributeItem.cs +++ b/src/BootstrapBlazor.Server/Data/AttributeItem.cs @@ -13,32 +13,32 @@ public class AttributeItem /// /// 获得/设置 参数 /// - public string Name { get; set; } = ""; + public string? Name { get; set; } /// /// 获得/设置 说明 /// - public string Description { get; set; } = ""; + public string? Description { get; set; } /// /// 获得/设置 类型 /// - public string Type { get; set; } = ""; + public string? Type { get; set; } /// /// 获得/设置 可选值 /// - public string ValueList { get; set; } = ""; + public string? ValueList { get; set; } /// /// 获得/设置 版本 /// - public string Version { get; set; } = "10.2.2"; + public string? Version { get; set; } /// /// 获得/设置 默认值 /// - public string DefaultValue { get; set; } = ""; + public string? DefaultValue { get; set; } /// /// 获得/设置 是否已弃用 diff --git a/src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs b/src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs index 90237440886..a68a022db28 100644 --- a/src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs +++ b/src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs @@ -18,6 +18,8 @@ public static class ComponentAttributeCacheService { private static readonly ConcurrentDictionary> _cache = new(); + private static XDocument? _xmlDoc; + /// /// 通过组件类型获取组件的 AttributeItem 列表 /// @@ -43,13 +45,21 @@ private static List GetAttributeCore(Type type) .ToArray(); } - var xmlDoc = GetXmlDocumentation(type.Assembly); + // 获得 BootstrapBlazor 程序集 xml 文档 + _xmlDoc ??= GetXmlDocumentation(typeof(BootstrapBlazorRoot).Assembly); + XDocument? xmlDoc = null; + if (type.Assembly.GetName().Name != "BootstrapBlazor") + { + // 扩展组件包 + xmlDoc = GetXmlDocumentation(type.Assembly); + } + return properties.Select(property => new AttributeItem { Name = property.Name, Type = GetFriendlyTypeName(property.PropertyType), Description = GetSummary(xmlDoc, property) ?? "", - Version = GetVersion(xmlDoc, property) ?? "10.0.0", + Version = GetVersion(xmlDoc, property), IsObsolete = property.GetCustomAttribute() != null }).OrderBy(i => i.Name).ToList(); } @@ -59,18 +69,19 @@ private static List GetAttributeCore(Type type) /// private static string? GetSummary(XDocument? xmlDoc, PropertyInfo property) { - if (xmlDoc == null) return null; - var type = property.DeclaringType ?? property.PropertyType; - var typeName = type.FullName ?? $"BootstrapBlazor.Components.{type.Name}"; + var typeName = $"BootstrapBlazor.Components.{type.Name}"; var memberName = $"P:{typeName}.{property.Name}"; var summaryElement = FindSummaryElement(xmlDoc, memberName); return summaryElement == null ? null : GetLocalizedSummary(summaryElement); } - private static XElement? FindSummaryElement(XDocument xmlDoc, string memberName) + private static XElement? FindSummaryElement(XDocument? xmlDoc, string memberName) { - var memberElement = xmlDoc.Descendants("member") + // 如果 xmlDoc 为空表示为 BootstrapBlazor 组件 + var memberElement = xmlDoc?.Descendants("member") + .FirstOrDefault(x => x.Attribute("name")?.Value == memberName) + ?? _xmlDoc?.Descendants("member") .FirstOrDefault(x => x.Attribute("name")?.Value == memberName); var summaryElement = memberElement?.Element("summary"); @@ -79,8 +90,8 @@ private static List GetAttributeCore(Type type) return null; } - var doc = summaryElement.Element("inheritdoc")?.Attribute("cref")?.Value; - return doc != null ? FindSummaryElement(xmlDoc, doc) : summaryElement; + var v = summaryElement.Element("inheritdoc")?.Attribute("cref")?.Value; + return v != null ? FindSummaryElement(xmlDoc, v) : summaryElement; } private static string? GetLocalizedSummary(XElement? summaryElement) diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs b/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs index 3f565a73513..8b4a130b23e 100644 --- a/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs +++ b/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs @@ -9,40 +9,41 @@ namespace BootstrapBlazor.Components; /// -/// EditorItem component +/// EditorItem 组件 /// EditorItem component /// public class EditorItem : ComponentBase, IEditorItem { /// /// 获得/设置 绑定字段值 - /// Gets or sets Field Value + /// Gets or sets the bound field value /// [Parameter] public TValue? Field { get; set; } /// /// 获得/设置 绑定字段值变化回调委托 - /// Gets or sets Field Value Changed Callback + /// Gets or sets the bound field value changed callback /// [Parameter] public EventCallback FieldChanged { get; set; } /// - /// + /// 获得/设置 属性类型 + /// Gets or sets the property type /// [NotNull] public Type? PropertyType { get; set; } /// /// 获得/设置 ValueExpression 表达式 - /// Gets or sets ValueExpression + /// Gets or sets the value expression /// [Parameter] public Expression>? FieldExpression { get; set; } /// - /// + /// /// [Parameter] [Obsolete("已弃用,是否可编辑改用 Readonly 参数,是否可见改用 Ignore 参数; Deprecated If it is editable, use the Readonly parameter. If it is visible, use the Ignore parameter.")] @@ -50,7 +51,8 @@ public class EditorItem : ComponentBase, IEditorItem public bool Editable { get; set; } = true; /// - /// + /// 获得/设置 是否忽略显示 + /// Gets or sets whether the field is ignored /// [Parameter] public bool? Ignore { get; set; } @@ -62,55 +64,64 @@ public class EditorItem : ComponentBase, IEditorItem public bool? Readonly { get; set; } /// - /// + /// 获得/设置 是否必填 + /// Gets or sets whether the field is required /// [Parameter] public bool? Required { get; set; } /// - /// + /// 获得/设置 必填错误信息 + /// Gets or sets the required error message /// [Parameter] public string? RequiredErrorMessage { get; set; } /// - /// + /// 获得/设置 是否跳过校验 + /// Gets or sets whether to skip validation /// [Parameter] public bool SkipValidate { get; set; } /// - /// + /// 获得/设置 是否显示标签提示 + /// Gets or sets whether to show the label tooltip /// [Parameter] public bool? ShowLabelTooltip { get; set; } /// - /// + /// 获得/设置 显示文本 + /// Gets or sets the display text /// [Parameter] public string? Text { get; set; } /// - /// + /// 获得/设置 步长 + /// Gets or sets the step value /// [Parameter] public string? Step { get; set; } /// - /// + /// 获得/设置 行数 + /// Gets or sets the row count /// [Parameter] public int Rows { get; set; } /// - /// + /// 获得/设置 列数 + /// Gets or sets the column count /// [Parameter] public int Cols { get; set; } /// - /// + /// 获得/设置 编辑模板 + /// Gets or sets the edit template /// [Parameter] public RenderFragment? EditTemplate { get; set; } @@ -130,49 +141,57 @@ public class EditorItem : ComponentBase, IEditorItem } /// - /// + /// 获得/设置 组件类型 + /// Gets or sets the component type /// [Parameter] public Type? ComponentType { get; set; } /// - /// + /// 获得/设置 组件参数集合 + /// Gets or sets the component parameters /// [Parameter] public IEnumerable>? ComponentParameters { get; set; } /// - /// + /// 获得/设置 占位符 + /// Gets or sets the placeholder text /// [Parameter] public string? PlaceHolder { get; set; } /// - /// + /// 获得/设置 显示顺序 + /// Gets or sets the display order /// [Parameter] public int Order { get; set; } /// - /// + /// 获得/设置 绑定数据集合 + /// Gets or sets the bound data items /// [Parameter] public IEnumerable? Items { get; set; } /// - /// + /// 获得/设置 Lookup 数据集合 + /// Gets or sets the lookup data items /// [Parameter] public IEnumerable? Lookup { get; set; } /// - /// + /// 获得/设置 选择时是否显示搜索 + /// Gets or sets whether to show search when selecting /// [Parameter] public bool ShowSearchWhenSelect { get; set; } /// - /// + /// 获得/设置 选择时是否固定搜索 + /// Gets or sets whether the search is fixed when selecting /// [Parameter] [Obsolete("已弃用,请删除;Deprecated, please delete")] @@ -180,37 +199,43 @@ public class EditorItem : ComponentBase, IEditorItem public bool IsFixedSearchWhenSelect { get; set; } /// - /// + /// 获得/设置 是否显示为气泡 + /// Gets or sets whether to show as a popover /// [Parameter] public bool IsPopover { get; set; } /// - /// + /// 获得/设置 Lookup 比较方式 + /// Gets or sets the lookup string comparison /// [Parameter] public StringComparison LookupStringComparison { get; set; } = StringComparison.OrdinalIgnoreCase; /// - /// + /// 获得/设置 Lookup 服务键 + /// Gets or sets the lookup service key /// [Parameter] public string? LookupServiceKey { get; set; } /// - /// + /// 获得/设置 Lookup 服务数据 + /// Gets or sets the lookup service data /// [Parameter] public object? LookupServiceData { get; set; } /// - /// + /// 获得/设置 Lookup 服务实例 + /// Gets or sets the lookup service instance /// [Parameter] public ILookupService? LookupService { get; set; } /// - /// + /// 获得/设置 校验规则集合 + /// Gets or sets the validation rules /// [Parameter] public List? ValidateRules { get; set; } @@ -219,13 +244,15 @@ public class EditorItem : ComponentBase, IEditorItem private List? EditorItems { get; set; } /// - /// + /// 获得/设置 分组名称 + /// Gets or sets the group name /// [Parameter] public string? GroupName { get; set; } /// - /// + /// 获得/设置 分组顺序 + /// Gets or sets the group order /// [Parameter] public int GroupOrder { get; set; } @@ -243,22 +270,20 @@ protected override void OnInitialized() _fieldIdentifier = FieldIdentifier.Create(FieldExpression); } - // 获取模型属性定义类型 - // Get model property definition type PropertyType = typeof(TValue); } private FieldIdentifier? _fieldIdentifier; /// - /// 获得 the 显示 name for the field. - /// Gets the display name for the field. + /// 获得显示名称 + /// Gets the display name /// public virtual string GetDisplayName() => Text ?? _fieldIdentifier?.GetDisplayName() ?? string.Empty; /// - /// 获得 the field name for the field. - /// Gets the field name for the field. + /// 获得字段名称 + /// Gets the field name /// public string GetFieldName() => _fieldIdentifier?.FieldName ?? string.Empty; } diff --git a/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs b/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs index afdc959752e..62e3c9de79b 100644 --- a/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs +++ b/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs @@ -6,166 +6,166 @@ namespace BootstrapBlazor.Components; /// -/// IEditorItem interface -/// IEditorItem interface +/// EditorItem 接口 +/// EditorItem interface /// public interface IEditorItem : ILookup { /// - /// 获得/设置 the 类型 of the bound column. - /// Gets or sets the type of the bound column. + /// 获得 绑定列的类型。 + /// Gets the type of the bound column. /// Type PropertyType { get; } /// - /// 获得/设置 是否 the current edit item is editable. 默认为 true. + /// 获得/设置 是否可编辑,默认为 true。 /// Gets or sets whether the current edit item is editable. Default is true. /// [Obsolete("Deprecated. Use the Visible parameter. IsVisibleWhenAdd should be used when creating a new one, and IsVisibleWhenEdit should be used when editing. Use the Readonly parameter for read-only. IsReadonlyWhenAdd should be used when creating a new one, and IsReadonlyWhenEdit should be used when editing.")] bool Editable { get; set; } /// - /// 获得/设置 是否 the current edit item is read-only. 默认为 false. + /// 获得/设置 是否为只读,默认为 false。 /// Gets or sets whether the current edit item is read-only. Default is false. /// bool? Readonly { get; set; } /// - /// 获得/设置 是否 the current edit item is ignored. 默认为 false. When set to true, the UI will not generate this column. - /// Gets or sets whether the current edit item is ignored. Default is false. When set to true, the UI will not generate this column. + /// 获得/设置 是否忽略当前编辑项,默认为 false,设置为 true 时 UI 不生成此列。 + /// Gets or sets whether the current edit item is ignored. Default is false. When true, the UI will not generate this column. /// bool? Ignore { get; set; } /// - /// 获得/设置 是否 to skip validation. 默认为 false. + /// 获得/设置 是否跳过校验,默认为 false。 /// Gets or sets whether to skip validation. Default is false. /// bool SkipValidate { get; set; } /// - /// 获得/设置 the header 显示 text. + /// 获得/设置 表头显示文本。 /// Gets or sets the header display text. /// string? Text { get; set; } /// - /// 获得/设置 是否 to show label tooltip. Mostly used when the label text is too long and gets truncated. 默认为 null. - /// Gets or sets whether to show label tooltip. Mostly used when the label text is too long and gets truncated. Default is null. + /// 获得/设置 是否显示标签提示,常用于标签文本过长被截断时,默认为 null。 + /// Gets or sets whether to show the label tooltip, usually when the label text is too long and truncated. Default is null. /// bool? ShowLabelTooltip { get; set; } /// - /// 获得/设置 the placeholder text. 默认为 null. + /// 获得/设置 占位符文本,默认为 null。 /// Gets or sets the placeholder text. Default is null. /// string? PlaceHolder { get; set; } /// - /// 获得/设置 the additional 数据 source, generally used for components like Select or CheckboxList that require additional configuration. + /// 获得/设置 附加数据源,通常用于 Select 或 CheckboxList 等需要额外配置的组件。 /// Gets or sets the additional data source, generally used for components like Select or CheckboxList that require additional configuration. /// IEnumerable? Items { get; set; } /// - /// 获得/设置 the step. 默认为 null. When set to "any", validation is ignored. + /// 获得/设置 步长,默认为 null,设置为 "any" 时忽略校验。 /// Gets or sets the step. Default is null. When set to "any", validation is ignored. /// string? Step { get; set; } /// - /// 获得/设置 the number of rows for a Textarea. 默认为 0. + /// 获得/设置 Textarea 的行数,默认为 0。 /// Gets or sets the number of rows for a Textarea. Default is 0. /// int Rows { get; set; } /// - /// 获得/设置 the field expand columns. 默认为 0. - /// Gets or sets the field expand columns. Default is 0. + /// 获得/设置 字段的列跨度,默认为 0。 + /// Gets or sets the field column span. Default is 0. /// int Cols { get; set; } /// - /// 获得/设置 the edit 模板. + /// 获得/设置 编辑模板。 /// Gets or sets the edit template. /// RenderFragment? EditTemplate { get; set; } /// - /// 获得/设置 the component 类型. 默认为 null. + /// 获得/设置 组件类型,默认为 null。 /// Gets or sets the component type. Default is null. /// Type? ComponentType { get; set; } /// - /// 获得/设置 the custom component parameters. 默认为 null. + /// 获得/设置 自定义组件参数,默认为 null。 /// Gets or sets the custom component parameters. Default is null. /// IEnumerable>? ComponentParameters { get; set; } /// - /// 获得/设置 是否 to show the search bar in the dropdown list. 默认为 false. + /// 获得/设置 是否在下拉列表中显示搜索框,默认为 false。 /// Gets or sets whether to show the search bar in the dropdown list. Default is false. /// bool ShowSearchWhenSelect { get; set; } /// - /// 获得/设置 是否 to allow fixed search box within dropdown. 默认为 false. - /// Gets or sets whether to allow fixed search box within dropdown. Default is false. + /// 获得/设置 是否在下拉中使用固定搜索框,默认为 false。 + /// Gets or sets whether to allow a fixed search box within the dropdown. Default is false. /// [Obsolete("已弃用,请删除;Deprecated, please delete")] [ExcludeFromCodeCoverage] bool IsFixedSearchWhenSelect { get; set; } /// - /// 获得/设置 是否 to use Popover to render the dropdown list. 默认为 false. + /// 获得/设置 是否使用 Popover 渲染下拉列表,默认为 false。 /// Gets or sets whether to use Popover to render the dropdown list. Default is false. /// bool IsPopover { get; set; } /// - /// 获得/设置 the custom validation rules. + /// 获得/设置 自定义验证规则。 /// Gets or sets the custom validation rules. /// List? ValidateRules { get; set; } /// - /// 获得 the 显示 name of the bound field. + /// 获得 绑定字段的显示名称。 /// Gets the display name of the bound field. /// string GetDisplayName(); /// - /// 获得 the field information of the bound field. - /// Gets the field information of the bound field. + /// 获得 绑定字段的字段名。 + /// Gets the field name of the bound field. /// string GetFieldName(); /// - /// 获得/设置 the order number. + /// 获得/设置 顺序号。 /// Gets or sets the order number. /// int Order { get; set; } /// - /// 获得/设置 the group name of the current 属性. + /// 获得/设置 当前属性的分组名称。 /// Gets or sets the group name of the current property. /// string? GroupName { get; set; } /// - /// 获得/设置 the group order of the current 属性. 默认为 0. + /// 获得/设置 当前属性的分组顺序,默认为 0。 /// Gets or sets the group order of the current property. Default is 0. /// int GroupOrder { get; set; } /// - /// 获得/设置 是否 the field is required. 默认为 null. + /// 获得/设置 是否为必填项,默认为 null。 /// Gets or sets whether the field is required. Default is null. /// bool? Required { get; set; } /// - /// 获得/设置 the error message when the required field is missing. 默认为 null. + /// 获得/设置 必填项缺失时的错误消息,默认为 null。 /// Gets or sets the error message when the required field is missing. Default is null. /// string? RequiredErrorMessage { get; set; }