public static ShapeLocator Parse(string identifier, Picture picture) { var shapeLocator = new ShapeLocator(); var identifierDecomp = identifier.Split(':'); int index; if (identifierDecomp.Length > 0 && int.TryParse(identifierDecomp[0], out index)) { try { shapeLocator.Shape = picture.ShapeAt(index); } catch (ArgumentOutOfRangeException) { throw new ArgumentException("Фигуры с таким индетефикатором " + identifier + " не существует"); } } else { throw new ArgumentException("Формат идеентификатора '" + identifier + "' не верен"); } if (identifierDecomp.Length > 1) { int[] underPosition = new int[identifierDecomp.Length - 1]; for (int i = 0; i < identifierDecomp.Length - 1; i++) { if (!int.TryParse(identifierDecomp[i + 1], out underPosition[i])) { throw new ArgumentException("Формат идеентификатора '" + identifier + "' не верен"); } } Search(shapeLocator, underPosition); } return(shapeLocator); }