Esempio n. 1
0
        /// <summary>
        /// Add a new parameter to the parameter array
        /// </summary>
        /// <param name="name">The name of the parameter</param>
        /// <param name="value">The value of the parameter</param>
        public void Add(string name, object value)
        {
            // Create a new parameter
            Parameter newParm = new Parameter(name, value);

            // Resize the array
            Array.Resize(ref mParameterArray, mParameterArray.GetLength(0) + 1);

            // Add the new parameter to the array
            mParameterArray[mParameterArray.GetUpperBound(0)] = newParm;
        }
Esempio n. 2
0
        /// <summary>
        /// Removes a specified parameter from the parameter array
        /// </summary>
        /// <param name="index">The 0-based index of the parameter to remove from the array</param>
        public void Remove(int index)
        {
            // make sure the index is within the bounds of the array
            if (index > mParameterArray.GetUpperBound(0))
            {
                throw (new Exception("Index is outside the bounds of the array"));
            }

            // declare a new parameter array
            Parameter[] newArray = new Parameter[0];
            int newArrayIndex = 0;

            // Loop through each parameter in the array only adding the ones that don't match the parameter name
            for (int i = 0; i <= mParameterArray.GetUpperBound(0); i++)
            {
                if (!i.Equals(index))
                {
                    // resize the new array
                    newArrayIndex++;
                    Array.Resize(ref newArray, newArrayIndex);
                    newArray[newArrayIndex - 1] = mParameterArray[i];
                }
            }

            // Set the member array equal to the new array
            mParameterArray = newArray;
        }
Esempio n. 3
0
        /// <summary>
        /// Removes a specified parameter from the parameter array
        /// </summary>
        /// <param name="name">The name of the parameter to remove</param>
        public void Remove(string name)
        {
            // declare a new parameter array
            Parameter[] newArray = new Parameter[0];
            int index = 0;

            // Loop through each parameter in the array only adding the ones that don't match the parameter name
            foreach (Parameter findParam in mParameterArray)
            {
                if (!findParam.Name.Equals(name))
                {
                    // resize the new array
                    index++;
                    Array.Resize(ref newArray, index);
                    newArray[index - 1] = findParam;
                }
            }

            // Set the member array equal to the new array
            mParameterArray = newArray;
        }