public CalcRelation AddRelationTo(CalcCell other, CalcChain chain) { if (_relationsTo.ContainsKey(other.Id)) return _relationsTo[other.Id]; var rel = new CalcRelation { CalcCellId = other.Id, CalcChainId = chain.Id }; _relationsTo.Add(other.Id, rel); return rel; }
public CalcRelation AddRelationFrom(CalcCell other, CalcChain chain) { if (_relationsFrom.ContainsKey(other.Id)) { return(_relationsFrom[other.Id]); } var rel = new CalcRelation { CalcCellId = other.Id, CalcChainId = chain.Id }; _relationsFrom.Add(other.Id, rel); return(rel); }
private CalcCell CreateAndAddNewCell(string address) { var newCell = CalcCell.Create(address, _context); _cells.Add(newCell.Id, newCell); var hashCode = GetHashCode(address); if (!_addressIndex.ContainsKey(hashCode)) { _addressIndex[hashCode] = new List <object>(); } _addressIndex[hashCode].Add(newCell.Id); return(newCell); }
public virtual CalcCell GetCell(string address) { CalcCell result = null; var loweredAddress = address.ToUpperInvariant(); var hashCode = GetHashCode(address); if (!_addressIndex.ContainsKey(hashCode)) { return(null); } foreach (var id in _addressIndex[hashCode]) { var candidate = _cells[id]; if (candidate.Address.ToUpperInvariant().Equals(loweredAddress)) { result = candidate; break; } } return(result); }
public void Add(CalcCell cell) { Count++; Current = cell; }