Made MessagingUtilities.CreateQueryString exception more useful.
[dotnetoauth.git] / src / DotNetOpenAuth / Messaging / EmptyList.cs
blobe9a83e9b02a648324b1aede4780b58a5ee03e64a
1 //-----------------------------------------------------------------------
2 // <copyright file="EmptyList.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
4 // </copyright>
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth.Messaging {
8 using System;
9 using System.Collections.Generic;
11 /// <summary>
12 /// An empty, read-only list.
13 /// </summary>
14 /// <typeparam name="T">The type the list claims to include.</typeparam>
15 internal class EmptyList<T> : IList<T> {
16 /// <summary>
17 /// The singleton instance of the empty list.
18 /// </summary>
19 internal static readonly EmptyList<T> Instance = new EmptyList<T>();
21 /// <summary>
22 /// Prevents a default instance of the EmptyList class from being created.
23 /// </summary>
24 private EmptyList() {
27 /// <summary>
28 /// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.
29 /// </summary>
30 /// <value></value>
31 /// <returns>
32 /// The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.
33 /// </returns>
34 public int Count {
35 get { return 0; }
38 /// <summary>
39 /// Gets a value indicating whether the <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
40 /// </summary>
41 /// <value></value>
42 /// <returns>true if the <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only; otherwise, false.
43 /// </returns>
44 public bool IsReadOnly {
45 get { return true; }
48 #region IList<T> Members
50 /// <summary>
51 /// Gets or sets the <typeparamref name="T"/> at the specified index.
52 /// </summary>
53 /// <param name="index">The index of the element in the list to change.</param>
54 public T this[int index] {
55 get {
56 throw new ArgumentOutOfRangeException("index");
59 set {
60 throw new ArgumentOutOfRangeException("index");
64 /// <summary>
65 /// Determines the index of a specific item in the <see cref="T:System.Collections.Generic.IList`1"/>.
66 /// </summary>
67 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.IList`1"/>.</param>
68 /// <returns>
69 /// The index of <paramref name="item"/> if found in the list; otherwise, -1.
70 /// </returns>
71 public int IndexOf(T item) {
72 return -1;
75 /// <summary>
76 /// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1"/> at the specified index.
77 /// </summary>
78 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
79 /// <param name="item">The object to insert into the <see cref="T:System.Collections.Generic.IList`1"/>.</param>
80 /// <exception cref="T:System.ArgumentOutOfRangeException">
81 /// <paramref name="index"/> is not a valid index in the <see cref="T:System.Collections.Generic.IList`1"/>.
82 /// </exception>
83 /// <exception cref="T:System.NotSupportedException">
84 /// The <see cref="T:System.Collections.Generic.IList`1"/> is read-only.
85 /// </exception>
86 public void Insert(int index, T item) {
87 throw new NotSupportedException();
90 /// <summary>
91 /// Removes the <see cref="T:System.Collections.Generic.IList`1"/> item at the specified index.
92 /// </summary>
93 /// <param name="index">The zero-based index of the item to remove.</param>
94 /// <exception cref="T:System.ArgumentOutOfRangeException">
95 /// <paramref name="index"/> is not a valid index in the <see cref="T:System.Collections.Generic.IList`1"/>.
96 /// </exception>
97 /// <exception cref="T:System.NotSupportedException">
98 /// The <see cref="T:System.Collections.Generic.IList`1"/> is read-only.
99 /// </exception>
100 public void RemoveAt(int index) {
101 throw new ArgumentOutOfRangeException("index");
104 #endregion
106 #region ICollection<T> Members
108 /// <summary>
109 /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>.
110 /// </summary>
111 /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
112 /// <exception cref="T:System.NotSupportedException">
113 /// The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
114 /// </exception>
115 public void Add(T item) {
116 throw new NotSupportedException();
119 /// <summary>
120 /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
121 /// </summary>
122 /// <exception cref="T:System.NotSupportedException">
123 /// The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
124 /// </exception>
125 public void Clear() {
126 throw new NotSupportedException();
129 /// <summary>
130 /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value.
131 /// </summary>
132 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
133 /// <returns>
134 /// true if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false.
135 /// </returns>
136 public bool Contains(T item) {
137 return false;
140 /// <summary>
141 /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index.
142 /// </summary>
143 /// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.ICollection`1"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param>
144 /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> at which copying begins.</param>
145 /// <exception cref="T:System.ArgumentNullException">
146 /// <paramref name="array"/> is null.
147 /// </exception>
148 /// <exception cref="T:System.ArgumentOutOfRangeException">
149 /// <paramref name="arrayIndex"/> is less than 0.
150 /// </exception>
151 /// <exception cref="T:System.ArgumentException">
152 /// <paramref name="array"/> is multidimensional.
153 /// -or-
154 /// <paramref name="arrayIndex"/> is equal to or greater than the length of <paramref name="array"/>.
155 /// -or-
156 /// The number of elements in the source <see cref="T:System.Collections.Generic.ICollection`1"/> is greater than the available space from <paramref name="arrayIndex"/> to the end of the destination <paramref name="array"/>.
157 /// -or-
158 /// Type <paramref name="T"/> cannot be cast automatically to the type of the destination <paramref name="array"/>.
159 /// </exception>
160 public void CopyTo(T[] array, int arrayIndex) {
163 /// <summary>
164 /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
165 /// </summary>
166 /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
167 /// <returns>
168 /// true if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1"/>.
169 /// </returns>
170 /// <exception cref="T:System.NotSupportedException">
171 /// The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
172 /// </exception>
173 public bool Remove(T item) {
174 return false;
177 #endregion
179 #region IEnumerable<T> Members
181 /// <summary>
182 /// Returns an enumerator that iterates through the collection.
183 /// </summary>
184 /// <returns>
185 /// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection.
186 /// </returns>
187 public IEnumerator<T> GetEnumerator() {
188 return System.Linq.Enumerable.Empty<T>().GetEnumerator();
191 #endregion
193 #region IEnumerable Members
195 /// <summary>
196 /// Returns an enumerator that iterates through a collection.
197 /// </summary>
198 /// <returns>
199 /// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
200 /// </returns>
201 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
202 return EmptyEnumerator.Instance;
205 #endregion