Canguro.Controller.CommandServices.parseItem C# (CSharp) Метод

parseItem() приватный Метод

Method that tries to assign waitingObj by parsing a string containing an Item index and a list containing the actual objects being refered to. If successful, it assigns waitingObj, selects the Item and sets the selectionFilter to None. If the string cannot be parsed or the index does not exist in the given list, it displays an error to the user and returns without changing anything.
private parseItem ( string parseStr, System list, string dataStr ) : void
parseStr string The user input
list System The list of Items where the search will be carried out (i.e. JointList)
dataStr string String with the Item being searched for in the proper language
Результат void
        private void parseItem(string parseStr, System.Collections.IList list, string dataStr)
        {
            if ((list != null) && (!string.IsNullOrEmpty(parseStr)))
            {
                try
                {
                    int index = int.Parse(parseStr.Trim());

                    if (index >= 0 && index < list.Count)
                        waitingObj = (Canguro.Model.Item)list[index];
                    else
                        throw new Canguro.Model.InvalidIndexException(dataStr);

                    if (waitingObj == null)
                        throw new Canguro.Model.InvalidIndexException(dataStr);
                }
                catch (FormatException)
                {
                    System.Windows.Forms.MessageBox.Show(
                        Culture.Get("enterDataError") + "'" + dataStr + "'",
                        Culture.Get("enterDataErrorTitle"), System.Windows.Forms.MessageBoxButtons.OK,
                        System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
                catch (Canguro.Model.InvalidIndexException)
                {
                    System.Windows.Forms.MessageBox.Show(
                        Culture.Get("enterDataIndexError").Replace("*type*", dataStr) + "'" + parseStr + "'",
                        Culture.Get("enterDataErrorTitle"), System.Windows.Forms.MessageBoxButtons.OK,
                        System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
            }

            if (waitingObj != null)
                ((Canguro.Model.Item)waitingObj).IsSelected = true;

            selectionFilter = WaitingFor.None;
        }