public void AddCell(string expression, string name, int ColId, int RowId) { bool add = false; Cell temp = new Cell(null, expression, ColId, RowId); if (!Table.TryAdd(name, temp)) { temp = Table[name]; } else { add = true; } try { LinkManager.FindLincs(name, expression, Table); } catch (ArgumentException e) { Table.Remove(name); throw e; } if (HasReferenceError(temp, name)) { if (add) { Table.Remove(name); } DelLink(temp); throw new StackOverflowException("Помилка. Комірка рекурсивно посилається на себе."); } dynamic value; try { value = Calculator.Evaluate(expression); } catch (Exception ex) { DelLink(temp); Table.Remove(name); throw ex; } Cell obj = new Cell(value, expression, ColId, RowId); obj.Name = name; if (Table.TryAdd(name, obj)) { } else { Table[name].Value = obj.Value; Table[name].Expression = obj.Expression; } LinkManager.FindLincs(name, expression, Table); LabCalculatorVisitor.tableIdentifier[name] = value; }