public static PersonInfoBase FromXML(string data) { try { #if SILVERLIGHT System.Xml.Linq.XDocument Doc = System.Xml.Linq.XDocument.Load(GenLib.Text.GetStream(data)); XPathNavigator navigator = Doc.CreateNavigator(); #else XPathDocument Doc = new XPathDocument(new StringReader(data)); XPathNavigator navigator = Doc.CreateNavigator(); #endif PersonInfoBase personInfo = new PersonInfoBase(); XPathNavigator node = navigator.SelectSingleNode("/PersonInfoBase"); string personId = node.GetAttribute("id", ""); string photoChoice = node.GetAttribute("pc", ""); string nameTrust = node.GetAttribute("nt", ""); string lockedContact = node.GetAttribute("lc", ""); personInfo.PersonId = int.Parse(personId); personInfo.Name = Text.DecodeXMLString(node.GetAttribute("name", "")); personInfo.AccountIdsStr = node.GetAttribute("accs", ""); if (!string.IsNullOrEmpty(photoChoice)) personInfo.PhotoChoice = short.Parse(photoChoice); if (!string.IsNullOrEmpty(nameTrust)) personInfo.NameTrust = short.Parse(nameTrust); personInfo.OutlookEntryID = Text.DecodeXMLString(node.GetAttribute("entry", "")); personInfo.CustomPhoto = Text.DecodeXMLString(node.GetAttribute("ph", "")); personInfo.FacebookPhoto = Text.DecodeXMLString(node.GetAttribute("fb", "")); personInfo.LinkedInPhoto = Text.DecodeXMLString(node.GetAttribute("li", "")); personInfo.TwitterPhoto = Text.DecodeXMLString(node.GetAttribute("tw", "")); personInfo.Occupation = Text.DecodeXMLString(node.GetAttribute("oc", "")); personInfo.CustomData = Text.DecodeXMLString(node.GetAttribute("cd", "")); if (!string.IsNullOrEmpty(lockedContact)) personInfo.LockedContact = lockedContact == "1"; return personInfo; } catch (Exception) { return null; } }
public PersonInfo(MailData mailData, PersonInfoBase personInfo) { _mailData = mailData; _peopleData = mailData.PeopleData; try { PersonId = personInfo.PersonId; Name = personInfo.Name; NameTrust = (EPersonNameTrust)personInfo.NameTrust; _accountIds = new List<int>(from id in (personInfo.AccountIdsStr).Split(new string[] { accountSep }, StringSplitOptions.RemoveEmptyEntries) select int.Parse(id)); CustomData = personInfo.CustomData; } catch (Exception ex) { GenLib.Log.LogService.LogException("PersonInfo constructor exception: ", ex); } }