private void RemoveRelation(SimRelation relation) { var r = _relations.FirstOrDefault(a => a.Equals(relation)) ?? throw new ArgumentException($"{relation} could not be found on the current graph"); // Change the state to removed r.ChangeState = ChangeState.Removed; }
private void UpdateRelation(SimRelation relation) { // Remove old version var removed = _relations.Remove(relation) ? true : throw new ArgumentException($"{relation} could not be found on the current graph"); // Add new version and change the state to Modified relation.ChangeState = ChangeState.Modified; _relations.Add(relation); }
private void AddRelation(SimRelation relation) { // Check if relation is already available on the graph if (_relations.Contains(relation)) { return; } // Add nodes AddNode(relation.Origin); AddNode(relation.Target); // Subscribe to this node _client?.ChangeTracker.SubscribeToChangeStateEvent(relation); // Change state of the relation to Added and add to graph relation.ChangeState = ChangeState.Added; _relations.Add(relation); }