protected override object DeserializeCore(LoadContext context, System.Xml.Linq.XElement xml, Type objectType, System.IO.Stream stream) { //<person nsid="12037949754@N01" ispro="0" iconserver="122" iconfarm="1"> // <username>bees</username> // <realname>Cal Henderson</realname> // <mbox_sha1sum>eea6cd28e3d0003ab51b0058a684d94980b727ac</mbox_sha1sum> // <location>Vancouver, Canada</location> // <photosurl>http://www.flickr.com/photos/bees/</photosurl> // <profileurl>http://www.flickr.com/people/bees/</profileurl> // <photos> // <firstdate>1071510391</firstdate> // <firstdatetaken>1900-09-02 09:11:24</firstdatetaken> // <count>449</count> // </photos> //</person> XElement personElement = xml; var user = new UserVm(personElement.Attribute("nsid").Value); user.ProfileIconUrl = UserVm.MakeIconUri(user.UserId, personElement.Attribute("iconfarm").Value, personElement.Attribute("iconserver").Value); bool success; user.UserName = personElement.Element("username").Value; user.FullName = TryGetValue(personElement, "realname", "", out success); return(user); }
protected override object DeserializeCore(LoadContext context, System.Xml.Linq.XElement xml, Type objectType, System.IO.Stream stream) { //<contacts page="1" pages="1" perpage="1000" total="3"> // <contact nsid="12037949629@N01" username="******" iconserver="1" // realname="Eric Costello" // friend="1" family="0" ignored="1" /> // <contact nsid="12037949631@N01" username="******" iconserver="1" // realname="Ben Cerveny" // friend="0" family="0" ignored="0" /> // <contact nsid="41578656547@N01" username="******" iconserver="1" // realname="Cal Henderson" // friend="1" family="1" ignored="0" /> //</contacts> ContactListVm contacts = new ContactListVm(); contacts.LoadContext = (IdLoadContext)context; foreach (var c in xml.Elements("contact")) { string nsid = c.Attribute("nsid").Value; UserVm userVm = new UserVm(nsid); userVm.UserName = c.Attribute("username").Value; var fullNameAttr = c.Attribute("realname"); if (fullNameAttr != null) { userVm.FullName = fullNameAttr.Value; } userVm.ProfileIconUrl = UserVm.MakeIconUri(nsid, c.Attribute("iconfarm").Value, c.Attribute("iconserver").Value); contacts.Contacts.Add(userVm); } return(contacts); }