📄 abstractparameterscollection.cs
字号:
/*
* Created by SharpDevelop.
* User: Forstmeier Peter
* Date: 15.06.2005
* Time: 10:50
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
namespace SharpReportCore
{
/// <summary>
/// A collection that stores <see cref='AbstractParameter'/> objects.
/// </summary>
[Serializable()]
public class AbstractParametersCollection : CollectionBase {
/// <summary>
/// Initializes a new instance of <see cref='AbstractParametersCollection'/>.
/// </summary>
public AbstractParametersCollection()
{
}
/// <summary>
/// Initializes a new instance of <see cref='AbstractParametersCollection'/> based on another <see cref='AbstractParametersCollection'/>.
/// </summary>
/// <param name='val'>
/// A <see cref='AbstractParametersCollection'/> from which the contents are copied
/// </param>
public AbstractParametersCollection(AbstractParametersCollection val)
{
this.AddRange(val);
}
/// <summary>
/// Initializes a new instance of <see cref='AbstractParametersCollection'/> containing any array of <see cref='AbstractParameter'/> objects.
/// </summary>
/// <param name='val'>
/// A array of <see cref='AbstractParameter'/> objects with which to intialize the collection
/// </param>
public AbstractParametersCollection(AbstractParameter[] val)
{
this.AddRange(val);
}
/// <summary>
/// Represents the entry at the specified index of the <see cref='AbstractParameter'/>.
/// </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 AbstractParameter this[int index] {
get {
return ((AbstractParameter)(List[index]));
}
set {
List[index] = value;
}
}
/// <summary>
/// Adds a <see cref='AbstractParameter'/> with the specified value to the
/// <see cref='AbstractParametersCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='AbstractParameter'/> to add.</param>
/// <returns>The index at which the new element was inserted.</returns>
/// <seealso cref='AbstractParametersCollection.AddRange'/>
public int Add(AbstractParameter val)
{
return List.Add(val);
}
/// <summary>
/// Copies the elements of an array to the end of the <see cref='AbstractParametersCollection'/>.
/// </summary>
/// <param name='val'>
/// An array of type <see cref='AbstractParameter'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='AbstractParametersCollection.Add'/>
public void AddRange(AbstractParameter[] val)
{
for (int i = 0; i < val.Length; i++) {
this.Add(val[i]);
}
}
/// <summary>
/// Adds the contents of another <see cref='AbstractParametersCollection'/> to the end of the collection.
/// </summary>
/// <param name='val'>
/// A <see cref='AbstractParametersCollection'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='AbstractParametersCollection.Add'/>
public void AddRange(AbstractParametersCollection val)
{
for (int i = 0; i < val.Count; i++)
{
this.Add(val[i]);
}
}
/// <summary>
/// Gets a value indicating whether the
/// <see cref='AbstractParametersCollection'/> contains the specified <see cref='AbstractParameter'/>.
/// </summary>
/// <param name='val'>The <see cref='AbstractParameter'/> to locate.</param>
/// <returns>
/// <see langword='true'/> if the <see cref='AbstractParameter'/> is contained in the collection;
/// otherwise, <see langword='false'/>.
/// </returns>
/// <seealso cref='AbstractParametersCollection.IndexOf'/>
public bool Contains(AbstractParameter val)
{
return List.Contains(val);
}
/// <summary>
/// Copies the <see cref='AbstractParametersCollection'/> 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='AbstractParametersCollection'/>.</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='AbstractParametersCollection'/> 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(AbstractParameter[] array, int index)
{
List.CopyTo(array, index);
}
/// <summary>
/// Returns the index of a <see cref='AbstractParameter'/> in
/// the <see cref='AbstractParametersCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='AbstractParameter'/> to locate.</param>
/// <returns>
/// The index of the <see cref='AbstractParameter'/> of <paramref name='val'/> in the
/// <see cref='AbstractParametersCollection'/>, if found; otherwise, -1.
/// </returns>
/// <seealso cref='AbstractParametersCollection.Contains'/>
public int IndexOf(AbstractParameter val)
{
return List.IndexOf(val);
}
/// <summary>
/// Inserts a <see cref='AbstractParameter'/> into the <see cref='AbstractParametersCollection'/> 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='AbstractParameter'/> to insert.</param>
/// <seealso cref='AbstractParametersCollection.Add'/>
public void Insert(int index, AbstractParameter val)
{
List.Insert(index, val);
}
AbstractParameter Find (string str) {
for (int i = 0;i < List.Count ; i ++) {
AbstractParameter p = (AbstractParameter)List[i];
if (p.ParameterName == str) {
return p;
}
}
return null;
}
public void SetParameterValue (string parameterName,object value) {
AbstractParameter par = Find (parameterName);
if (par == null) {
string str = String.Format("Parameter {0} not found",parameterName);
throw new ArgumentException(str);
} else {
par.DefaultValue = value;
}
}
/// <summary>
/// Returns an enumerator that can iterate through the <see cref='AbstractParametersCollection'/>.
/// </summary>
/// <seealso cref='IEnumerator'/>
public new AbstractParameterEnumerator GetEnumerator()
{
return new AbstractParameterEnumerator(this);
}
/// <summary>
/// Removes a specific <see cref='AbstractParameter'/> from the <see cref='AbstractParametersCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='AbstractParameter'/> to remove from the <see cref='AbstractParametersCollection'/>.</param>
/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
public void Remove(AbstractParameter val)
{
List.Remove(val);
}
/// <summary>
/// Enumerator that can iterate through a AbstractParametersCollection.
/// </summary>
/// <seealso cref='IEnumerator'/>
/// <seealso cref='AbstractParametersCollection'/>
/// <seealso cref='AbstractParameter'/>
public class AbstractParameterEnumerator : IEnumerator
{
IEnumerator baseEnumerator;
IEnumerable temp;
/// <summary>
/// Initializes a new instance of <see cref='AbstractParameterEnumerator'/>.
/// </summary>
public AbstractParameterEnumerator(AbstractParametersCollection mappings)
{
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator();
}
/// <summary>
/// Gets the current <see cref='AbstractParameter'/> in the <seealso cref='AbstractParametersCollection'/>.
/// </summary>
public AbstractParameter Current {
get {
return ((AbstractParameter)(baseEnumerator.Current));
}
}
object IEnumerator.Current {
get {
return baseEnumerator.Current;
}
}
/// <summary>
/// Advances the enumerator to the next <see cref='AbstractParameter'/> of the <see cref='AbstractParametersCollection'/>.
/// </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='AbstractParametersCollection'/>.
/// </summary>
public void Reset()
{
baseEnumerator.Reset();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -