I'm sure this violates a principle...
In ASP.NET 1.1, the Page class' Culture and UICulture properties are write-only. I've often wondered why this is, since the set accessors just set the current thread's CurrentCulture and CurrentUICulture properties, and the get accessors could just get their culture names:
protected string Culture
{
set
{
Thread.CurrentThread.CurrentCulture = HttpServerUtility.CreateReadOnlyCultureInfo(value);
}
// I'd have added:
// get
// {
// return Thread.CurrentThread.CurrentCulture.Name;
// }
}
protected string UICulture
{
set
{
Thread.CurrentThread.CurrentUICulture = HttpServerUtility.CreateReadOnlyCultureInfo(value);
}
// I'd have added:
// get
// {
// return Thread.CurrentThread.CurrentUICulture.Name;
// }
}
In ASP.NET 2.0 beta 2, you can set and get Culture and UICulture, but the get accessors return the current thread's cultures' display names:
protected string Culture
{
set
{
// This is more complicated because of the "auto" culture.
}
get
{
return Thread.CurrentThread.CurrentCulture.DisplayName;
}
}
protected string UICulture
{
set
{
// This is more complicated because of the "auto" culture.
}
get
{
return Thread.CurrentThread.CurrentUICulture.DisplayName;
}
}
Why is this worth mentioning?
First, you can't create an instance of CultureInfo given a display name, so you can't round-trip Culture and UICulture values like this:
string oldCulture = Culture;
Culture = "ja-JP";
// ...
Culture = oldCulture;
Even this won't work:
Culture = Culture;
Second, display names are in the language of the localized version of the .NET Framework, not in the language of the current culture. Unless your application is monolingual and you're using a version of the .NET Framework localized for that language, you won't want to show your users display names.
So what gives? Shouldn't property values round-trip unless there's a good reason not to? Can anyone tell me what the reason would be in this case?
Colin
02:46 PM | Colin

TrackBacks
# norvasc ?????????¦???????08:13 AM | norvasc
# plavix ?????????¦???????08:45 AM | plavix
# mosquito ringtone ?????????¦???????03:41 AM | mosquito ringtone
# free nokia ringtones ?????????¦???????02:58 AM | free nokia ringtones