Newtonsoft.Json.JsonReader.Close C# (CSharp) Method

Close() public method

Changes the reader's state to JsonReader.State.Closed.
public Close ( ) : void
return void
        public virtual void Close()
        {
            _currentState = State.Closed;
            _tokenType = JsonToken.None;
            _value = null;
        }

Usage Example

示例#1
0
        //get the current account balance for a given user
        public string getAccountBalance(string username, string apiKey, ref NotifyIcon notifyIcon)
        {
            string accountBalance = "0.0";

            try
            {
                if (String.IsNullOrEmpty(username))
                    return "";

                WebClient client = new WebClient();
                string urlFormat = "http://marketplace.envato.com/api/v1/" + username + "/" + apiKey + "/account.json";
                Uri url = new Uri(string.Format(urlFormat));
                string data = client.DownloadString(url);

                using (JsonReader reader = new JsonReader(new StringReader(data)))
                {
                    while (reader.Read())
                    {
                        //users++;
                        if ((string)reader.Value == "balance")
                        {
                            reader.Read();
                            accountBalance = (string)reader.Value;
                        }
                    }
                    reader.Close(); //close the reader object
                }
            }
            catch (WebException webex)
            {
                notifyIcon.ShowBalloonTip(180000000, "EnvatoTracker error!", "Error querying the api - invalid api key maybe?\n\nError:"+webex, ToolTipIcon.None);
            }

            return accountBalance;
        }
All Usage Examples Of Newtonsoft.Json.JsonReader::Close