~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to RSS/src/RSS.NET/RssModuleItem.cs

  • Committer: Christopher Halse Rogers
  • Date: 2008-08-24 08:44:24 UTC
  • mfrom: (244.1.2 do-plugins)
  • Revision ID: raof@ubuntu.com-20080824084424-8gp5ff6v9nku9z21
Merge in the tip of 0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* RssModuleItem.cs
 
2
 * ================
 
3
 * 
 
4
 * RSS.NET (http://rss-net.sf.net/)
 
5
 * Copyright � 2002 - 2005 George Tsiokos. All Rights Reserved.
 
6
 * 
 
7
 * RSS 2.0 (http://blogs.law.harvard.edu/tech/rss)
 
8
 * RSS 2.0 is offered by the Berkman Center for Internet & Society at 
 
9
 * Harvard Law School under the terms of the Attribution/Share Alike 
 
10
 * Creative Commons license.
 
11
 * 
 
12
 * Permission is hereby granted, free of charge, to any person obtaining 
 
13
 * a copy of this software and associated documentation files (the "Software"), 
 
14
 * to deal in the Software without restriction, including without limitation 
 
15
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 
16
 * and/or sell copies of the Software, and to permit persons to whom the 
 
17
 * Software is furnished to do so, subject to the following conditions:
 
18
 * 
 
19
 * The above copyright notice and this permission notice shall be included in all
 
20
 * copies or substantial portions of the Software.
 
21
 * 
 
22
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 
23
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 
24
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 
25
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 
26
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 
27
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
 
28
 * THE SOFTWARE.
 
29
 */
 
30
using System;
 
31
using System.Collections.Generic;
 
32
 
 
33
namespace Rss
 
34
{
 
35
        /// <summary>A module may contain any number of items (either channel-based or item-based).</summary>
 
36
        [Serializable()]
 
37
                public class RssModuleItem : RssElement
 
38
        {
 
39
                private bool _bRequired = false;
 
40
                private string _sElementName = RssDefault.String;
 
41
                private string _sElementText = RssDefault.String;
 
42
                private List<RssModuleItem> _rssSubElements = new List<RssModuleItem>();
 
43
 
 
44
                /// <summary>Initialize a new instance of the RssModuleItem class</summary>
 
45
                public RssModuleItem()
 
46
                {
 
47
                }
 
48
 
 
49
                /// <summary>Initialize a new instance of the RssModuleItem class</summary>
 
50
                /// <param name="name">The name of this RssModuleItem.</param>
 
51
                public RssModuleItem(string name)
 
52
                {
 
53
                        this._sElementName = RssDefault.Check(name);
 
54
                }
 
55
 
 
56
                /// <summary>Initialize a new instance of the RssModuleItem class</summary>
 
57
                /// <param name="name">The name of this RssModuleItem.</param>
 
58
                /// <param name="required">Is text required for this RssModuleItem?</param>
 
59
                public RssModuleItem(string name, bool required) : this(name)
 
60
                {
 
61
                        this._bRequired = required;
 
62
                }
 
63
 
 
64
                /// <summary>Initialize a new instance of the RssModuleItem class</summary>
 
65
                /// <param name="name">The name of this RssModuleItem.</param>
 
66
                /// <param name="text">The text contained within this RssModuleItem.</param>
 
67
                public RssModuleItem(string name, string text) : this(name)
 
68
                {
 
69
                        this._sElementText = RssDefault.Check(text);
 
70
                }
 
71
 
 
72
                /// <summary>Initialize a new instance of the RssModuleItem class</summary>
 
73
                /// <param name="name">The name of this RssModuleItem.</param>
 
74
                /// <param name="required">Is text required for this RssModuleItem?</param>
 
75
                /// <param name="text">The text contained within this RssModuleItem.</param>
 
76
                public RssModuleItem(string name, bool required, string text) : this(name, required)
 
77
                {
 
78
                        this._sElementText = RssDefault.Check(text);
 
79
                }
 
80
 
 
81
                /// <summary>Initialize a new instance of the RssModuleItem class</summary>
 
82
                /// <param name="name">The name of this RssModuleItem.</param>
 
83
                /// <param name="text">The text contained within this RssModuleItem.</param>
 
84
                /// <param name="subElements">The sub-elements of this RssModuleItem (if any exist).</param>
 
85
                public RssModuleItem(string name, string text, List<RssModuleItem> subElements) : this(name, text)
 
86
                {
 
87
                        this._rssSubElements = subElements;
 
88
                }
 
89
 
 
90
                /// <summary>Initialize a new instance of the RssModuleItem class</summary>
 
91
                /// <param name="name">The name of this RssModuleItem.</param>
 
92
                /// <param name="required">Is text required for this RssModuleItem?</param>
 
93
                /// <param name="text">The text contained within this RssModuleItem.</param>
 
94
                /// <param name="subElements">The sub-elements of this RssModuleItem (if any exist).</param>
 
95
                public RssModuleItem(string name, bool required, string text, List<RssModuleItem> subElements) : this(name, required, text)
 
96
                {
 
97
                        this._rssSubElements = subElements;
 
98
                }
 
99
 
 
100
                /// <summary>Returns a string representation of the current Object.</summary>
 
101
                /// <returns>The item's title, description, or "RssModuleItem" if the title and description are blank.</returns>
 
102
                public override string ToString()
 
103
                {
 
104
                        if (Name != RssDefault.String)
 
105
                                return Name;
 
106
                        else if (Text != RssDefault.String)
 
107
                                return Text;
 
108
                        else
 
109
                                return "RssModuleItem";
 
110
                }
 
111
 
 
112
                /// <summary>
 
113
                /// The name of this RssModuleItem.
 
114
                /// </summary>
 
115
                public string Name
 
116
                {
 
117
                        get { return this._sElementName; }
 
118
                        set { this._sElementName = RssDefault.Check(value); }
 
119
                }
 
120
 
 
121
                /// <summary>
 
122
                /// The text contained within this RssModuleItem.
 
123
                /// </summary>
 
124
                public string Text
 
125
                {
 
126
                        get { return this._sElementText; }
 
127
                        set { this._sElementText = RssDefault.Check(value); }
 
128
                }
 
129
 
 
130
                /// <summary>
 
131
                /// The sub-elements of this RssModuleItem (if any exist).
 
132
                /// </summary>
 
133
                public List<RssModuleItem> SubElements
 
134
                {
 
135
                        get { return this._rssSubElements; }
 
136
                        set { this._rssSubElements = value;}
 
137
                }
 
138
 
 
139
                /// <summary>
 
140
                /// Is text for this element required?
 
141
                /// </summary>
 
142
                public bool IsRequired
 
143
                {
 
144
                        get { return this._bRequired; }
 
145
                }
 
146
        }
 
147
}