using System; using System.Collections; using System.Xml.Serialization; using System.Xml.Schema; using System.Xml; namespace FlickrNet { /// /// The context of the current photo, as returned by /// , /// /// and methods. /// public class Context { /// /// The number of photos in the current context, e.g. Group, Set or photostream. /// public long Count; /// /// The next photo in the context. /// public ContextPhoto NextPhoto; /// /// The previous photo in the context. /// public ContextPhoto PreviousPhoto; } /// /// Temporary class used to excapsulate the context count property. /// [System.Serializable] public class ContextCount { /// /// Default constructor. /// public ContextCount() { } /// /// The number of photos in the context. /// [XmlText()] public long Count; } /// /// The next (or previous) photo in the current context. /// [System.Serializable] public class ContextPhoto { /// /// The id of the next photo. Will be "0" if this photo is the last. /// [XmlAttribute("id", Form=XmlSchemaForm.Unqualified)] public string PhotoId; /// /// The secret for the photo. /// [XmlAttribute("secret", Form=XmlSchemaForm.Unqualified)] public string Secret; /// /// The title of the next photo in context. /// [XmlAttribute("title", Form=XmlSchemaForm.Unqualified)] public string Title; /// /// The URL, in the given context, for the next or previous photo. /// [XmlAttribute("url", Form=XmlSchemaForm.Unqualified)] public string Url; /// /// The URL for the thumbnail of the photo. /// [XmlAttribute("thumb", Form=XmlSchemaForm.Unqualified)] public string Thumbnail; } /// /// All contexts that a photo is in. /// public class AllContexts { private ContextSet[] _sets; private ContextGroup[] _groups; /// /// An array of objects for the current photo. /// public ContextSet[] Sets { get { return _sets; } } /// /// An array of objects for the current photo. /// public ContextGroup[] Groups { get { return _groups; } } internal AllContexts(XmlElement[] elements) { ArrayList sets = new ArrayList(); ArrayList groups = new ArrayList(); foreach(XmlElement element in elements) { if( element.Name == "set" ) { ContextSet aset = new ContextSet(); aset.PhotosetId = element.Attributes["id"].Value; aset.Title = element.Attributes["title"].Value; sets.Add(aset); } if( element.Name == "pool" ) { ContextGroup agroup = new ContextGroup(); agroup.GroupId = element.Attributes["id"].Value; agroup.Title = element.Attributes["title"].Value; groups.Add(agroup); } } _sets = new ContextSet[sets.Count]; sets.CopyTo(_sets); _groups = new ContextGroup[groups.Count]; groups.CopyTo(_groups); } } /// /// A set context for a photo. /// public class ContextSet { /// /// The Photoset ID of the set the selected photo is in. /// public string PhotosetId; /// /// The title of the set the selected photo is in. /// public string Title; } /// /// A group context got a photo. /// public class ContextGroup { /// /// The Group ID for the group that the selected photo is in. /// public string GroupId; /// /// The title of the group that then selected photo is in. /// public string Title; } }