Пример #1
0
        /// <summary>
        /// Gets the item at index.
        /// </summary>
        /// <returns>The
        /// <see cref="BuildingFormulas.CubicAreaSquareRectangle"/>.</returns>
        /// <param name="index">Index of item to get.</param>
        public static SquareRectangleVolumeStruct GetItemAt(int index)
        {
            SquareRectangleVolumeStruct dataStruct = new
                                                     SquareRectangleVolumeStruct();

            try
            {
                methodName = "public static " +
                             "CubicAreaSquareRectangle GetItemAt(int index)";

                dataStruct = dataList[index];

                return(dataStruct);
            }
            catch (IndexOutOfRangeException ex)
            {
                myMsg.BuildErrorString(
                    MyClassName,
                    methodName,
                    errMsg,
                    ex.ToString());

                return(dataStruct);
            }
            catch (ArgumentException ex)
            {
                myMsg.BuildErrorString(
                    MyClassName,
                    methodName,
                    errMsg,
                    ex.ToString());

                return(dataStruct);
            }
        }
Пример #2
0
        /// <summary>
        /// Adds the new item.
        /// </summary>
        /// <returns><c>true</c>, if new item was added,
        /// <c>false</c> otherwise.</returns>
        /// <param name="dataStruct">Data struct.</param>
        public static bool AddNewItem(SquareRectangleVolumeStruct dataStruct)
        {
            bool retVal = false;

            methodName = "public static bool AddNewItem(" +
                         "CubicAreaSquareRectangle dataStruct)";

            try
            {
                dataList.Add(dataStruct);

                // All ok return true.
                retVal = true;

                return(retVal);
            }
            catch (ArgumentException ex)
            {
                errMsg = "Invalid argument passed.";
                myMsg.BuildErrorString(
                    MyClassName,
                    methodName,
                    errMsg,
                    ex.ToString());
                return(false);
            }
        }