private void parseGuid(JToken data) { guid = new TypeAndValue(); string value = data.SelectToken("value").ToString(); guid.Value = value; JToken type = data.SelectToken("flags"); if (type.Count() > 0) { guid.Type = type[0].ToString(); } }
private void parsePhone(JToken data) { string value = data.SelectToken("value").ToString(); TypeAndValue item = new TypeAndValue(); item.Value = value; JToken type = data.SelectToken("flags"); if (type.Count() > 0) { item.Type = type[0].ToString(); } phones.Add(item); }
public void parseContactFromJToken(JToken token) { bareData = token.ToString(); id = token.SelectToken("id").ToString(); first_name = token.SelectToken("first_name").ToString(); last_name = token.SelectToken("last_name").ToString(); name = token.SelectToken("name").ToString(); is_friend = (bool)token.SelectToken("is_friend"); is_favorite = (bool)token.SelectToken("is_favorite"); JToken emailsToken = token.SelectToken("emails"); if (emailsToken != null) { JToken tempToken = emailsToken.SelectToken("personal"); //string preferredEmail = emailsToken.SelectToken("preferred").ToString(); //string accountEmail = emailsToken.SelectToken("account").ToString(); string personalEmail = tempToken != null ? tempToken.ToString() : ""; tempToken = emailsToken.SelectToken("business"); string businessEmail = tempToken != null ? tempToken.ToString() : ""; tempToken = emailsToken.SelectToken("other"); string otherEmail = tempToken != null ? tempToken.ToString() : ""; if (!String.IsNullOrEmpty(personalEmail)) { TypeAndValue typeAndVal = new TypeAndValue(); typeAndVal.Type = "personal"; typeAndVal.Value = personalEmail; emails.Add(typeAndVal); } if (!String.IsNullOrEmpty(businessEmail)) { TypeAndValue typeAndVal = new TypeAndValue(); typeAndVal.Type = "business"; typeAndVal.Value = businessEmail; emails.Add(typeAndVal); } if (!String.IsNullOrEmpty(otherEmail)) { TypeAndValue typeAndVal = new TypeAndValue(); typeAndVal.Type = "other"; typeAndVal.Value = otherEmail; emails.Add(typeAndVal); } } JToken phonesToken = token.SelectToken("phones"); if (phonesToken != null) { JToken tempToken = phonesToken.SelectToken("personal"); string personalPhone = tempToken != null ? tempToken.ToString() : ""; tempToken = phonesToken.SelectToken("business"); string businessPhone = tempToken != null ? tempToken.ToString() : ""; tempToken = phonesToken.SelectToken("mobile"); string mobilePhone = tempToken != null ? tempToken.ToString() : ""; tempToken = phonesToken.SelectToken("home_fax"); string homeFax = tempToken != null ? tempToken.ToString() : ""; tempToken = phonesToken.SelectToken("work_fax"); string workFax = tempToken != null ? tempToken.ToString() : ""; if (!String.IsNullOrEmpty(personalPhone)) { TypeAndValue typeAndVal = new TypeAndValue(); typeAndVal.Type = "personal"; typeAndVal.Value = personalPhone; phones.Add(typeAndVal); } if (!String.IsNullOrEmpty(businessPhone)) { TypeAndValue typeAndVal = new TypeAndValue(); typeAndVal.Type = "business"; typeAndVal.Value = businessPhone; phones.Add(typeAndVal); } if (!String.IsNullOrEmpty(mobilePhone)) { TypeAndValue typeAndVal = new TypeAndValue(); typeAndVal.Type = "mobile"; typeAndVal.Value = mobilePhone; phones.Add(typeAndVal); } if (!String.IsNullOrEmpty(homeFax)) { TypeAndValue typeAndVal = new TypeAndValue(); typeAndVal.Type = "home_fax"; typeAndVal.Value = homeFax; phones.Add(typeAndVal); } if (!String.IsNullOrEmpty(workFax)) { TypeAndValue typeAndVal = new TypeAndValue(); typeAndVal.Type = "work_fax"; typeAndVal.Value = workFax; phones.Add(typeAndVal); } } }
private void parseLink(JToken data) { link = new TypeAndValue(); string value = data.SelectToken("value").ToString(); link.Value = value; JToken type = data.SelectToken("flags"); if (type.Count() > 0) { link.Type = type[0].ToString(); } }
private void parseEmailAddresses(JToken data) { foreach (JToken address in data) { TypeAndValue item = new TypeAndValue(); string field = address.SelectToken("field").ToString(); string label = address.SelectToken("label").ToString(); item.Value = field; item.Type = label; emailAddresses.Add(item); } }
private void parsePhones(JToken data) { foreach (JToken phone in data) { TypeAndValue item = new TypeAndValue(); string field = phone.SelectToken("field").ToString(); string label = phone.SelectToken("label").ToString(); item.Value = field; item.Type = label; phones.Add(item); } }
// parse private void parseUrls(JToken data) { foreach (JToken url in data) { TypeAndValue item = new TypeAndValue(); string field = url.SelectToken("field").ToString(); string label = url.SelectToken("label").ToString(); item.Value = field; item.Type = label; urls.Add(item); } }
private void parsePhone(JToken data) { foreach (JToken email in data) { TypeAndValue item = new TypeAndValue(); string emailVal = email.SelectToken("$t").ToString(); string rel = email.SelectToken("rel").ToString(); string[] relSplit = rel.Split('#'); item.Value = emailVal; item.Type = relSplit[relSplit.Length - 1]; phones.Add(item); } }
private void parsePhone(JToken data) { foreach (JToken email in data) { try { TypeAndValue item = new TypeAndValue(); string emailVal = email.SelectToken("$t").ToString(); string rel = email.SelectToken("rel").ToString(); string[] relSplit = rel.Split('#'); item.Value = emailVal; item.Type = relSplit[relSplit.Length - 1]; phones.Add(item); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } }