📄 memocollection.cs
字号:
using System;
using System.Collections;
namespace Org.InteliIM.Activities.Memos
{
/// <summary>
/// A collection that stores <see cref='Memo'/> objects.
/// </summary>
[Serializable()]
public class MemoCollection : CollectionBase
{
/// <summary>
/// Initializes a new instance of <see cref='MemoCollection'/>.
/// </summary>
public MemoCollection()
{
}
/// <summary>
/// Initializes a new instance of <see cref='MemoCollection'/> based on another <see cref='MemoCollection'/>.
/// </summary>
/// <param name='val'>
/// A <see cref='MemoCollection'/> from which the contents are copied
/// </param>
public MemoCollection(MemoCollection val)
{
this.AddRange(val);
}
/// <summary>
/// Initializes a new instance of <see cref='MemoCollection'/> containing any array of <see cref='Memo'/> objects.
/// </summary>
/// <param name='val'>
/// A array of <see cref='Memo'/> objects with which to intialize the collection
/// </param>
public MemoCollection(Memo[] val)
{
this.AddRange(val);
}
/// <summary>
/// Represents the entry at the specified index of the <see cref='Memo'/>.
/// </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 Memo this[int index]
{
get
{
return ((Memo)(List[index]));
}
set
{
List[index] = value;
}
}
/// <summary>
/// Adds a <see cref='Memo'/> with the specified value to the
/// <see cref='MemoCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Memo'/> to add.</param>
/// <returns>The index at which the new element was inserted.</returns>
/// <seealso cref='MemoCollection.AddRange'/>
public int Add(Memo val)
{
return List.Add(val);
}
/// <summary>
/// Copies the elements of an array to the end of the <see cref='MemoCollection'/>.
/// </summary>
/// <param name='val'>
/// An array of type <see cref='Memo'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='MemoCollection.Add'/>
public void AddRange(Memo[] val)
{
for (int i = 0; i < val.Length; i++)
{
this.Add(val[i]);
}
}
/// <summary>
/// Adds the contents of another <see cref='MemoCollection'/> to the end of the collection.
/// </summary>
/// <param name='val'>
/// A <see cref='MemoCollection'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='MemoCollection.Add'/>
public void AddRange(MemoCollection val)
{
for (int i = 0; i < val.Count; i++)
{
this.Add(val[i]);
}
}
/// <summary>
/// Gets a value indicating whether the
/// <see cref='MemoCollection'/> contains the specified <see cref='Memo'/>.
/// </summary>
/// <param name='val'>The <see cref='Memo'/> to locate.</param>
/// <returns>
/// <see langword='true'/> if the <see cref='Memo'/> is contained in the collection;
/// otherwise, <see langword='false'/>.
/// </returns>
/// <seealso cref='MemoCollection.IndexOf'/>
public bool Contains(Memo val)
{
return List.Contains(val);
}
/// <summary>
/// Copies the <see cref='MemoCollection'/> 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='MemoCollection'/>.</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='MemoCollection'/> 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(Memo[] array, int index)
{
List.CopyTo(array, index);
}
/// <summary>
/// Returns the index of a <see cref='Memo'/> in
/// the <see cref='MemoCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Memo'/> to locate.</param>
/// <returns>
/// The index of the <see cref='Memo'/> of <paramref name='val'/> in the
/// <see cref='MemoCollection'/>, if found; otherwise, -1.
/// </returns>
/// <seealso cref='MemoCollection.Contains'/>
public int IndexOf(Memo val)
{
return List.IndexOf(val);
}
/// <summary>
/// Inserts a <see cref='Memo'/> into the <see cref='MemoCollection'/> 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='Memo'/> to insert.</param>
/// <seealso cref='MemoCollection.Add'/>
public void Insert(int index, Memo val)
{
List.Insert(index, val);
}
/// <summary>
/// Returns an enumerator that can iterate through the <see cref='MemoCollection'/>.
/// </summary>
/// <seealso cref='IEnumerator'/>
public new DiaryEnumerator GetEnumerator()
{
return new DiaryEnumerator(this);
}
/// <summary>
/// Removes a specific <see cref='Memo'/> from the <see cref='MemoCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Memo'/> to remove from the <see cref='MemoCollection'/>.</param>
/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
public void Remove(Memo val)
{
List.Remove(val);
}
/// <summary>
/// Enumerator that can iterate through a DiaryCollection.
/// </summary>
/// <seealso cref='IEnumerator'/>
/// <seealso cref='MemoCollection'/>
/// <seealso cref='Memo'/>
public class DiaryEnumerator : IEnumerator
{
IEnumerator baseEnumerator;
IEnumerable temp;
/// <summary>
/// Initializes a new instance of <see cref='DiaryEnumerator'/>.
/// </summary>
public DiaryEnumerator(MemoCollection mappings)
{
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator();
}
/// <summary>
/// Gets the current <see cref='Memo'/> in the <seealso cref='MemoCollection'/>.
/// </summary>
public Memo Current
{
get
{
return ((Memo)(baseEnumerator.Current));
}
}
object IEnumerator.Current
{
get
{
return baseEnumerator.Current;
}
}
/// <summary>
/// Advances the enumerator to the next <see cref='Memo'/> of the <see cref='MemoCollection'/>.
/// </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='MemoCollection'/>.
/// </summary>
public void Reset()
{
baseEnumerator.Reset();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -