The VCD file for the app contains only a couple of City phrases, which does not make for a very useful weather app.
To remedy the situation, the viewmodel contains a dictionary of WOEIDs keyed by city name, as shown in the following excerpt:
Dictionary<string, string> woeDictionary = new Dictionary<string, string>
{
{"Zurich Switzerland", "784794"},
{"Canberra Australia", "1100968"},
{"Bellevue Washington", "2362031"},
{"London England", "44418"},
{"Prague Czech Republic", "796597"},
{"Bangkok Thailand", "1225448"},
{"Paris France", "615702"},
{"Moscow Russia", "2122265"},
{"Madrid Spain", "766273"},
{"New Delhi India", "2295019"},
};
Rather than hardcoding the list of city names in the VCD file, city names are added programmatically by modifying the weather VoiceCommandSet
object.
The viewmodel’s Initialize
method updates the phrase list by calling UpdatePhraseListAsync
on the weather command set, as shown in the following excerpt:
commandSet.UpdatePhraseListAsync("City", woeDictionary.Keys);
UpdatePhraseListAsync
expects the name of the phrase list, in this case City, and an IEnumerable<string>
of new spoken phrases.
The capability to programmatically update a phrase list means that you are able to provide a single source of truth for the phrase list and affords you the option of retrieving phrase list data from the cloud.
3.147.83.176