Posts tagged c#
WPF Localization Extension v2.1.0
0The new version arrives and I have some highlights to point out:
- First of all: ITS FREE (and will stay free)
- Obtain stable results in
- WPF applications using .NET 3.5 and higher
- New: Silverlight 5.0 applications
- New: Localization source/provider can be changed freely at arbitrary nodes
- Use the Provider property in LocalizeDictionary to change the provider for the particular sub tree
- Use the DefaultProvider property to set the provider for the whole application
- Built-in RESX provider for resource file lookup (Default) – fully backward compatible to older versions of this extension
- Interface for custom providers
- Notification about provider changes and errors
- Get the list of all available cultures from a provider – or just take the bindable merged list from LocalizeDictionary
- CSV provider project in the Tests folder as an example for custom providers
(more…)
WCF & WebAPI JSON Dictionary
0Imagine you want to serialize a Dictionary<string, string> for wcf json output.
The JSON output would look like this:
[
{
Key: "key1",
Value: "value1"
},
{
Key: "key2",
Value: "value2"
}
]
But you want a correct JSON dictionary format:
{
"key1": "value1",
"key2": "value2"
}
Determine ClickOnce UpdateUri / Install Address
0Its hard to find Informations about the place where the UpdateUri is saved on a windows machine.
The only information i was found is where the binaries of a ClickOnce application is stored.
This whould be:
C:\Users\UserName\AppData\Local\Apps\2.0\ (Vista)
C:\Documents and Settings\UserName\Local Settings\Apps\2.0\ (XP)
The UpdateUri of a particular application can be found in the registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\[APP-ID]\UrlUpdateInfo
The key will contain a string like this:
http://somedomain.com/ApplicationName/ApplicationName.application
If this address is called in the browser (InternetExplorer or Firefox with AddOn), the application starts to install.
If you change the ApplicationName.application to publish.htm, a install page will be displayed.
Binding to an anonymous type
0Try to imagine that you have a list of complex classes and you just want to display just a bunch of properties.
For example:
Person.Firstname,
Person.Lastname,
Person.Address.District.Name,
Person.Cars[0].Brand,
Person.Cars[1].Brand
I was playing around with ValueConverter and found out, that i can return an anonymous type out of the converter and bind it to a textblock’s content.
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Persons) { var persons = (Persons)value; var query = from person in persons let firstname = person.Firstname let lastname = person.Lastname let districtname = person.Address.District.Name let car1 = person.Cars[0].Brand let car2 = person.Cars[1].Brand select new { Firstname = firstname, Lastname = lastname, Districtname = districtname, Car1 = car1, Car2 = car2 }; return query; } return value; } |
Updating the values as you maybe guess don’t work, but if you dont want to write complex bindings you can use this technique to archive the result.
NeutralResourcesLanguageAttribute is Evil for ResourceFiles
0Imagine this:
Two Resource files named Strings.resx and Strings.de.resx.
The first (neutral) contains english content, the second german content.
If you ask youself over and over again why the f**k the ResourceManager returns the neutral language even you use the specified language “de”, look into your AssemblyInfo.cs file.
If there is a [assembly: NeutralResourcesLanguage("de")], the ResourceManager from this Assembly thinks you want to get the neutral language if you ask for “de” explicit.
This attribute is used to overrule the neutral settings to a specific one.
Deleting this from your AssemblyInfo.cs can help you realy much in this case.

