File: Tags.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 (82 lines) | stat: -rw-r--r-- 1,843 bytes parent folder | download | duplicates (3)
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
using System;
using System.Xml;

namespace FlickrNet
{
	/// <summary>
	/// A simple tag class, containing a tag name and optional count (for <see cref="Flickr.TagsGetListUserPopular()"/>)
	/// </summary>
	public class Tag
	{
		private string _tagName;
		private int _count;

		/// <summary>
		/// The name of the tag.
		/// </summary>
		public string TagName
		{
			get { return _tagName; }
		}

		/// <summary>
		/// The poularity of the tag. Will be 0 where the popularity is not retreaved.
		/// </summary>
		public int Count
		{
			get { return _count; }
		}

		internal Tag(XmlNode node)
		{
			if( node.Attributes["count"] != null ) _count = Convert.ToInt32(node.Attributes["count"].Value);
			_tagName = node.InnerText;
		}

		internal Tag(string tagName, int count)
		{
			_tagName = tagName;
			_count = count;
		}
	}

	/// <summary>
	/// Raw tags, as returned by the <see cref="Flickr.TagsGetListUserRaw(string)"/> method.
	/// </summary>
	public class RawTag
	{
		private string _cleanTag;
		private string[] _rawTags = new string[0];

		/// <summary>
		/// An array of strings containing the raw tags returned by the method.
		/// </summary>
		public string[] RawTags
		{
			get { return _rawTags; }
		}

		/// <summary>
		/// The clean tag.
		/// </summary>
		public string CleanTag
		{
			get { return _cleanTag; }
		}
		
		internal RawTag(XmlNode node)
		{
			if( node.Attributes.GetNamedItem("clean") == null ) throw new ResponseXmlException("clean attribute not found");
			_cleanTag = node.Attributes.GetNamedItem("clean").Value;

			XmlNodeList list = node.SelectNodes("raw");
			_rawTags = new string[list.Count];

			for(int i = 0; i < list.Count; i++)
			{
				XmlNode rawNode = list[i];
				_rawTags[i] = rawNode.InnerText;
			}
		}
	}
}