You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Moved from Codeplex: https://gw2dotnet.codeplex.com/workitem/1239]
Right now, it is still possible to pass in a CultureInfo object per request. I'm thinking about switching to Thread.CurrentUICulture for /v2 services. You'd still be able to pass your own CultureInfo object into the constructor. When you don't, the current UI culture will be used instead.
I settled on a slightly different approach. I did not like the ability to change the language once a service object has been created. If a user wants to retrieve details in 4 languages, then the user should create 4 different instances of the endpoint class.
In the end, I decided on factory classes that configure endpoints for a given language. The endpoint object itself is immutable, so the language cannot be changed afterwards.
Example: ItemFactory for /v2/items
This factory class has an indexed property that expects a two-letter language code. It uses that index value to configure the item service object.
// Explicit languagevaritemsDE=GW2.V2.Items["de"];varitemsEN=GW2.V2.Items["en"];varitemsES=GW2.V2.Items["es"];varitemsFR=GW2.V2.Items["fr"];// Default language (API decides what language to use)varitems=GW2.V2.Items.Default;
System language
So what about automatically determining the preferred language? I was thinking about adding helpers to the factory class.
[Moved from Codeplex: https://gw2dotnet.codeplex.com/workitem/1239]
Right now, it is still possible to pass in a CultureInfo object per request. I'm thinking about switching to
Thread.CurrentUICulture
for /v2 services. You'd still be able to pass your ownCultureInfo
object into the constructor. When you don't, the current UI culture will be used instead.Info: http://msdn.microsoft.com/en-us/library/system.threading.thread.currentuiculture(v=vs.100).aspx
Ruhrpottpatriot wrote Sep 22, 2014 at 4:31 AM
StevenLiekens wrote Oct 19, 2014 at 6:02 AM
The text was updated successfully, but these errors were encountered: