weatherreportentrycollection.cs
来自「该源代码用 C# 写成」· CS 代码 · 共 231 行
CS
231 行
using System;
using System.Collections;
namespace Org.InteliIM.Activities.Weather
{
/// <summary>
/// A collection that stores <see cref='WeatherReportEntry'/> objects.
/// </summary>
[Serializable()]
public class WeatherReportEntryCollection : CollectionBase {
/// <summary>
/// Initializes a new instance of <see cref='WeatherReportEntryCollection'/>.
/// </summary>
public WeatherReportEntryCollection()
{
}
/// <summary>
/// Initializes a new instance of <see cref='WeatherReportEntryCollection'/> based on another <see cref='WeatherReportEntryCollection'/>.
/// </summary>
/// <param name='val'>
/// A <see cref='WeatherReportEntryCollection'/> from which the contents are copied
/// </param>
public WeatherReportEntryCollection(WeatherReportEntryCollection val)
{
this.AddRange(val);
}
/// <summary>
/// Initializes a new instance of <see cref='WeatherReportEntryCollection'/> containing any array of <see cref='WeatherReportEntry'/> objects.
/// </summary>
/// <param name='val'>
/// A array of <see cref='WeatherReportEntry'/> objects with which to intialize the collection
/// </param>
public WeatherReportEntryCollection(WeatherReportEntry[] val)
{
this.AddRange(val);
}
/// <summary>
/// Represents the entry at the specified index of the <see cref='WeatherReportEntry'/>.
/// </summary>
/// <param name='index'>The zero-based index of the entry to locate in the collection.</param>
/// <value>The entry at the specified index of the collection.</value>
/// <exception cref='ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
public WeatherReportEntry this[int index] {
get {
return ((WeatherReportEntry)(List[index]));
}
set {
List[index] = value;
}
}
/// <summary>
/// Adds a <see cref='WeatherReportEntry'/> with the specified value to the
/// <see cref='WeatherReportEntryCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='WeatherReportEntry'/> to add.</param>
/// <returns>The index at which the new element was inserted.</returns>
/// <seealso cref='WeatherReportEntryCollection.AddRange'/>
public int Add(WeatherReportEntry val)
{
return List.Add(val);
}
/// <summary>
/// Copies the elements of an array to the end of the <see cref='WeatherReportEntryCollection'/>.
/// </summary>
/// <param name='val'>
/// An array of type <see cref='WeatherReportEntry'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='WeatherReportEntryCollection.Add'/>
public void AddRange(WeatherReportEntry[] val)
{
for (int i = 0; i < val.Length; i++) {
this.Add(val[i]);
}
}
/// <summary>
/// Adds the contents of another <see cref='WeatherReportEntryCollection'/> to the end of the collection.
/// </summary>
/// <param name='val'>
/// A <see cref='WeatherReportEntryCollection'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='WeatherReportEntryCollection.Add'/>
public void AddRange(WeatherReportEntryCollection val)
{
for (int i = 0; i < val.Count; i++)
{
this.Add(val[i]);
}
}
/// <summary>
/// Gets a value indicating whether the
/// <see cref='WeatherReportEntryCollection'/> contains the specified <see cref='WeatherReportEntry'/>.
/// </summary>
/// <param name='val'>The <see cref='WeatherReportEntry'/> to locate.</param>
/// <returns>
/// <see langword='true'/> if the <see cref='WeatherReportEntry'/> is contained in the collection;
/// otherwise, <see langword='false'/>.
/// </returns>
/// <seealso cref='WeatherReportEntryCollection.IndexOf'/>
public bool Contains(WeatherReportEntry val)
{
return List.Contains(val);
}
/// <summary>
/// Copies the <see cref='WeatherReportEntryCollection'/> values to a one-dimensional <see cref='Array'/> instance at the
/// specified index.
/// </summary>
/// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='WeatherReportEntryCollection'/>.</param>
/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
/// <exception cref='ArgumentException'>
/// <para><paramref name='array'/> is multidimensional.</para>
/// <para>-or-</para>
/// <para>The number of elements in the <see cref='WeatherReportEntryCollection'/> is greater than
/// the available space between <paramref name='arrayIndex'/> and the end of
/// <paramref name='array'/>.</para>
/// </exception>
/// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
/// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
/// <seealso cref='Array'/>
public void CopyTo(WeatherReportEntry[] array, int index)
{
List.CopyTo(array, index);
}
/// <summary>
/// Returns the index of a <see cref='WeatherReportEntry'/> in
/// the <see cref='WeatherReportEntryCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='WeatherReportEntry'/> to locate.</param>
/// <returns>
/// The index of the <see cref='WeatherReportEntry'/> of <paramref name='val'/> in the
/// <see cref='WeatherReportEntryCollection'/>, if found; otherwise, -1.
/// </returns>
/// <seealso cref='WeatherReportEntryCollection.Contains'/>
public int IndexOf(WeatherReportEntry val)
{
return List.IndexOf(val);
}
/// <summary>
/// Inserts a <see cref='WeatherReportEntry'/> into the <see cref='WeatherReportEntryCollection'/> at the specified index.
/// </summary>
/// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
/// <param name='val'>The <see cref='WeatherReportEntry'/> to insert.</param>
/// <seealso cref='WeatherReportEntryCollection.Add'/>
public void Insert(int index, WeatherReportEntry val)
{
List.Insert(index, val);
}
/// <summary>
/// Returns an enumerator that can iterate through the <see cref='WeatherReportEntryCollection'/>.
/// </summary>
/// <seealso cref='IEnumerator'/>
public new WeatherReportEntryEnumerator GetEnumerator()
{
return new WeatherReportEntryEnumerator(this);
}
/// <summary>
/// Removes a specific <see cref='WeatherReportEntry'/> from the <see cref='WeatherReportEntryCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='WeatherReportEntry'/> to remove from the <see cref='WeatherReportEntryCollection'/>.</param>
/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
public void Remove(WeatherReportEntry val)
{
List.Remove(val);
}
/// <summary>
/// Enumerator that can iterate through a WeatherReportEntryCollection.
/// </summary>
/// <seealso cref='IEnumerator'/>
/// <seealso cref='WeatherReportEntryCollection'/>
/// <seealso cref='WeatherReportEntry'/>
public class WeatherReportEntryEnumerator : IEnumerator
{
IEnumerator baseEnumerator;
IEnumerable temp;
/// <summary>
/// Initializes a new instance of <see cref='WeatherReportEntryEnumerator'/>.
/// </summary>
public WeatherReportEntryEnumerator(WeatherReportEntryCollection mappings)
{
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator();
}
/// <summary>
/// Gets the current <see cref='WeatherReportEntry'/> in the <seealso cref='WeatherReportEntryCollection'/>.
/// </summary>
public WeatherReportEntry Current {
get {
return ((WeatherReportEntry)(baseEnumerator.Current));
}
}
object IEnumerator.Current {
get {
return baseEnumerator.Current;
}
}
/// <summary>
/// Advances the enumerator to the next <see cref='WeatherReportEntry'/> of the <see cref='WeatherReportEntryCollection'/>.
/// </summary>
public bool MoveNext()
{
return baseEnumerator.MoveNext();
}
/// <summary>
/// Sets the enumerator to its initial position, which is before the first element in the <see cref='WeatherReportEntryCollection'/>.
/// </summary>
public void Reset()
{
baseEnumerator.Reset();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?