本文介绍了本地化mscorlib.dll资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ILSpy中打开了mscorlib,在资源文件夹中看到了
I've opened mscorlib in ILSpy and I see in resources folder:
Name, Value
[Format_InvalidString, Input string was not in a correct format.]
有什么办法可以本地化这个字符串?
Is there any way to localize this string?
(上下文:每当输入错误的数字时,silverlight应用程序都会引发此消息,仅更改此数字比编写转换器并在数百个地方应用它要容易得多.
(Context: silverlight app throws this message whenever incorrect number is entered and it would be much easier to just change this than to write converter and apply it in hundreds of places).
推荐答案
唯一可行的解决方案是:
The only solution that works is this:
public partial class MyEntity
{
public string MyField_string
{
get
{
return MyField.ToString();
}
set
{
decimal res = 0;
var b = Decimal.TryParse(value, out res);
if (!b)
throw new ArgumentException("Localized message");
else
this.MyField = Math.Round(res, 2);
}
}
partial void OnMyFieldChanged()
{
RaisePropertyChanged("MyField_string");
}
}
然后绑定到MyField_string
而不是MyField
.
这篇关于本地化mscorlib.dll资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!