コード例 #1
0
        private void btnFind_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Song convertedSong = new Song();
                convertedSong.Title = txtTitle.Text;
                convertedSong.Title = convertedSong.Title.ToLower();
                convertedSong.Title = convertedSong.Title.Replace(' ', '_');
                Request request = new Request();
                String  Input   = request.GetResponse(convertedSong.Title);

                JsonInput inputObject = new JsonInput();
                inputObject.Json = Input;

                JSONConverter converterObject = new JSONConverter();
                convertedSong  = converterObject.Convert(inputObject);
                txtLyrics.Text = convertedSong.Lyrics;
            }
            catch (System.Net.WebException)
            {
                System.Windows.MessageBox.Show("Song Not Found", "404 Error");
            }
        }
コード例 #2
0
        /*
         * MS: Great example of encapsulating both the parameter and the return
         * variable.
         */
        public Song Convert(JsonInput input)
        {
            Song thisSong = JsonConvert.DeserializeObject <Song>(input.Json);

            return(thisSong);
        }