命名调整

This commit is contained in:
GG Z
2025-07-12 23:31:32 +08:00
parent 4d35cadb56
commit 6d96da6f90
88 changed files with 3975 additions and 2763 deletions

View File

@@ -9,7 +9,7 @@ public class CornerRadiusToDoubleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is CornerRadius))
if (value is not CornerRadius)
{
return default(double);
}

View File

@@ -11,7 +11,7 @@
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is double))
if (value is not double)
{
return default(CornerRadius);
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Markup;
namespace AntdWpf.Converters;
/// <summary>
/// 构造单例的Converter的markup
/// </summary>
/// <example>
/// 示例代码:
/// <code>
/// <![CDATA[<TextBlock Text="{Binding Value, Converter={local:GenericConverterExtension Type={x:Type local:MyValueConverter}}}" />]]>
/// </code>
/// </example>
public class GenericConverterExtension : MarkupExtension
{
public Type Type { get; set; }
private static readonly Dictionary<Type, object> _instances = new();
public override object ProvideValue(IServiceProvider serviceProvider)
{
if (Type == null || !typeof(IValueConverter).IsAssignableFrom(Type)|| !typeof(IMultiValueConverter).IsAssignableFrom(Type))
throw new InvalidOperationException("类型必须是值转换器");
if (!_instances.TryGetValue(Type, out var instance))
_instances[Type] = instance = Activator.CreateInstance(Type);
return instance;
}
}

View File

@@ -12,7 +12,7 @@
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is Thickness))
if (value is not Thickness)
{
return default(double);
}