protected override object DeserializeCore(LoadContext context, XElement xml, Type objectType, Stream stream) { // <photo id="2733" secret="123456" server="12" // isfavorite="0" license="3" rotation="90" // originalsecret="1bc09ce34a" originalformat="png"> // <owner nsid="12037949754@N01" username="******" // realname="Cal Henderson" location="Bedford, UK" /> // <title>orford_castle_taster</title> // <description>hello!</description> // <visibility ispublic="1" isfriend="0" isfamily="0" /> // <dates posted="1100897479" taken="2004-11-19 12:51:19" // takengranularity="0" lastupdate="1093022469" /> // <permissions permcomment="3" permaddmeta="2" /> // <editability cancomment="1" canaddmeta="1" /> // <comments>1</comments> // <notes> // <note id="313" author="12037949754@N01" // authorname="Bees" x="10" y="10" // w="50" h="50">foo</note> // </notes> // <tags> // <tag id="1234" author="12037949754@N01" raw="woo yay">wooyay</tag> // <tag id="1235" author="12037949754@N01" raw="hoopla">hoopla</tag> // </tags> // <urls> // <url type="photopage">http://www.flickr.com/photos/bees/2733/</url> // </urls> //</photo> var vm = new PhotoVm(context.Identity); bool s; vm.Title = TryGetValue(xml, "title", null, out s); vm.Description = TryGetValue(xml, "description", null, out s); var owner = xml.Element("owner"); vm.OwnerId = TryGetValue(owner, "nsid", null, out s); var dates = xml.Element("dates"); vm.Posted = FromUnixTime(TryGetValue(dates, "posted", null, out s)); var taken = TryGetValue(dates, "taken", null, out s); if (taken != null) { vm.Taken = taken; } vm.Updated = FromUnixTime(TryGetValue(dates, "lastupdate", null, out s)); ObservableCollection <PhotoTag> tags = new ObservableCollection <PhotoTag>(); foreach (var tag in xml.Element("tags").Elements("tag")) { bool success; PhotoTag pt = new PhotoTag { Tag = TryGetValue(tag, "raw", "", out success), RawTag = tag.Value, ID = TryGetValue(tag, "id", null, out success) }; tags.Add(pt); } vm.Tags = tags; return(vm); }
protected override object DeserializeCore(LoadContext context, XElement xml, Type objectType, Stream stream) { // <photo id="2733" secret="123456" server="12" // isfavorite="0" license="3" rotation="90" // originalsecret="1bc09ce34a" originalformat="png"> // <owner nsid="12037949754@N01" username="******" // realname="Cal Henderson" location="Bedford, UK" /> // <title>orford_castle_taster</title> // <description>hello!</description> // <visibility ispublic="1" isfriend="0" isfamily="0" /> // <dates posted="1100897479" taken="2004-11-19 12:51:19" // takengranularity="0" lastupdate="1093022469" /> // <permissions permcomment="3" permaddmeta="2" /> // <editability cancomment="1" canaddmeta="1" /> // <comments>1</comments> // <notes> // <note id="313" author="12037949754@N01" // authorname="Bees" x="10" y="10" // w="50" h="50">foo</note> // </notes> // <tags> // <tag id="1234" author="12037949754@N01" raw="woo yay">wooyay</tag> // <tag id="1235" author="12037949754@N01" raw="hoopla">hoopla</tag> // </tags> // <urls> // <url type="photopage">http://www.flickr.com/photos/bees/2733/</url> // </urls> //</photo> var vm = new PhotoVm(context.Identity); bool s; vm.Title = TryGetValue(xml, "title", null, out s); vm.Description = TryGetValue(xml, "description", null, out s); var owner = xml.Element("owner"); vm.OwnerId = TryGetValue(owner, "nsid", null, out s); var dates = xml.Element("dates"); vm.Posted = FromUnixTime(TryGetValue(dates, "posted", null, out s)); var taken = TryGetValue(dates, "taken", null, out s); if (taken != null) { vm.Taken = taken; } vm.Updated = FromUnixTime(TryGetValue(dates, "lastupdate", null, out s)); ObservableCollection<PhotoTag> tags = new ObservableCollection<PhotoTag>(); foreach (var tag in xml.Element("tags").Elements("tag")) { bool success; PhotoTag pt = new PhotoTag { Tag = TryGetValue(tag, "raw", "", out success), RawTag = tag.Value, ID = TryGetValue(tag, "id", null, out success) }; tags.Add(pt); } vm.Tags = tags; return vm; }