File: Context.cs

package info (click to toggle)
libflickrnet 25277-6
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 628 kB
  • ctags: 1,355
  • sloc: cs: 7,136; makefile: 24; sh: 13; ansic: 6
file content (173 lines) | stat: -rw-r--r-- 4,207 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
using System;
using System.Collections;
using System.Xml.Serialization;
using System.Xml.Schema;
using System.Xml;

namespace FlickrNet
{
	/// <summary>
	/// The context of the current photo, as returned by
	/// <see cref="Flickr.PhotosGetContext"/>,
	/// <see cref="Flickr.PhotosetsGetContext"/>
	///  and <see cref="Flickr.GroupPoolGetContext"/> methods.
	/// </summary>
	public class Context
	{
		/// <summary>
		/// The number of photos in the current context, e.g. Group, Set or photostream.
		/// </summary>
		public long Count;
		/// <summary>
		/// The next photo in the context.
		/// </summary>
		public ContextPhoto NextPhoto;
		/// <summary>
		/// The previous photo in the context.
		/// </summary>
		public ContextPhoto PreviousPhoto;
	}

	/// <summary>
	/// Temporary class used to excapsulate the context count property.
	/// </summary>
	[System.Serializable]
	public class ContextCount
	{
		/// <summary>
		/// Default constructor.
		/// </summary>
		public ContextCount()
		{
		}

		/// <summary>
		/// The number of photos in the context.
		/// </summary>
		[XmlText()]
		public long Count;
	}

	/// <summary>
	/// The next (or previous) photo in the current context.
	/// </summary>
	[System.Serializable]
	public class ContextPhoto
	{
		/// <summary>
		/// The id of the next photo. Will be "0" if this photo is the last.
		/// </summary>
		[XmlAttribute("id", Form=XmlSchemaForm.Unqualified)]
		public string PhotoId;

		/// <summary>
		/// The secret for the photo.
		/// </summary>
		[XmlAttribute("secret", Form=XmlSchemaForm.Unqualified)]
		public string Secret;

		/// <summary>
		/// The title of the next photo in context.
		/// </summary>
		[XmlAttribute("title", Form=XmlSchemaForm.Unqualified)]
		public string Title;

		/// <summary>
		/// The URL, in the given context, for the next or previous photo.
		/// </summary>
		[XmlAttribute("url", Form=XmlSchemaForm.Unqualified)]
		public string Url;

		/// <summary>
		/// The URL for the thumbnail of the photo.
		/// </summary>
		[XmlAttribute("thumb", Form=XmlSchemaForm.Unqualified)]
		public string Thumbnail;
	}

	/// <summary>
	/// All contexts that a photo is in.
	/// </summary>
	public class AllContexts
	{
		private ContextSet[] _sets;
		private ContextGroup[] _groups;

		/// <summary>
		/// An array of <see cref="ContextSet"/> objects for the current photo.
		/// </summary>
		public ContextSet[] Sets
		{
			get { return _sets; }
		}

		/// <summary>
		/// An array of <see cref="ContextGroup"/> objects for the current photo.
		/// </summary>
		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);
		}
	}

	/// <summary>
	/// A set context for a photo.
	/// </summary>
	public class ContextSet
	{
		/// <summary>
		/// The Photoset ID of the set the selected photo is in.
		/// </summary>
		public string PhotosetId;
		/// <summary>
		/// The title of the set the selected photo is in.
		/// </summary>
		public string Title;
	}

	/// <summary>
	/// A group context got a photo.
	/// </summary>
	public class ContextGroup
	{
		/// <summary>
		/// The Group ID for the group that the selected photo is in.
		/// </summary>
		public string GroupId;
		/// <summary>
		/// The title of the group that then selected photo is in.
		/// </summary>
		public string Title;
	}
}