/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListLexiconsResponse response = new ListLexiconsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Lexicons", targetDepth)) { var unmarshaller = new ListUnmarshaller <LexiconDescription, LexiconDescriptionUnmarshaller>(LexiconDescriptionUnmarshaller.Instance); response.Lexicons = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } } return(response); }
public static void ListLexicons() { AmazonPollyClient client = new AmazonPollyClient(); ListLexiconsRequest listLexiconsRequest = new ListLexiconsRequest(); try { String nextToken; do { ListLexiconsResponse listLexiconsResponse = client.ListLexicons(listLexiconsRequest); nextToken = listLexiconsResponse.NextToken; listLexiconsResponse.NextToken = nextToken; Console.WriteLine("All voices: "); foreach (LexiconDescription lexiconDescription in listLexiconsResponse.Lexicons) { LexiconAttributes attributes = lexiconDescription.Attributes; Console.WriteLine("Name: " + lexiconDescription.Name + ", Alphabet: " + attributes.Alphabet + ", LanguageCode: " + attributes.LanguageCode + ", LastModified: " + attributes.LastModified + ", LexemesCount: " + attributes.LexemesCount + ", LexiconArn: " + attributes.LexiconArn + ", Size: " + attributes.Size); } } while (nextToken != null); } catch (Exception e) { Console.WriteLine("Exception caught: " + e.Message); } }
void ShowLexiconsList() { if (!RefreshConnection()) { return; } List <LexiconDescription> lexicons = new List <LexiconDescription>(); try { lexiconsList.Clear(); ListLexiconsRequest req = new ListLexiconsRequest(); ListLexiconsResponse llr = _pc.ListLexicons(req); lexicons = llr.Lexicons; } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); return; } foreach (LexiconDescription ld in lexicons) { string lexName = ld.Name; lexiconsList.Add(lexName); } string joinedList = "Lexicons: \n\n" + string.Join("\n", lexiconsList); joinedList += "\n\n\n Would you like to go to Amazon Console to manage lexicons?"; if (MessageBox.Show(joinedList, "Available Lexicons", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { System.Diagnostics.Process.Start("http://" + _region + ".console.aws.amazon.com/polly/home/Lexicons"); } }