fix(i18n): 解决绑定值类型检查问题
- 添加类型检查确保只有 BindingBase 类型被直接添加 - 对非 BindingBase 类型的值创建新的 Binding 对象 - 防止运行时类型转换异常 - 提高代码健壮性
This commit is contained in:
@@ -20,6 +20,11 @@ internal class I18NBinding : MultiBinding
|
|||||||
Bindings.Add(new Binding { Source = I18NConfig.Manager, Path = nameof(I18NConfig.Manager.Culture) });
|
Bindings.Add(new Binding { Source = I18NConfig.Manager, Path = nameof(I18NConfig.Manager.Culture) });
|
||||||
Bindings.Add(new Binding { Source = key });
|
Bindings.Add(new Binding { Source = key });
|
||||||
foreach (var value in values)
|
foreach (var value in values)
|
||||||
Bindings.Add(value);
|
{
|
||||||
|
if (value is BindingBase binding)
|
||||||
|
Bindings.Add(binding);
|
||||||
|
else
|
||||||
|
Bindings.Add(new Binding { Source = value });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user