protected void AddSagaKey(string name, string value) { var newKeys = new MultiValueDictionary <string, string>(keys); newKeys.Add(name, value); Publish(new SagaKeysChangedEvent( newKeys .Select(x => new KeyValuePair <string, ImmutableList <string> >(x.Key, x.Value.ToImmutableList())) .ToImmutableDictionary())); }
protected void RemoveSagaKey(string name, string value) { bool changed = false; var newKeys = keys.Select(x => { if (x.Key == name) { var newValues = x.Value.ToList(); changed = newValues.Remove(value); return(new KeyValuePair <string, ImmutableList <string> >(x.Key, newValues.ToImmutableList())); } return(new KeyValuePair <string, ImmutableList <string> >(x.Key, x.Value.ToImmutableList())); }).ToImmutableDictionary(); if (changed) { Publish(new SagaKeysChangedEvent(newKeys)); } }
public int GetMaxDegree() { return(_vertexEdgeDictionary.Select(x => x.Value.Sum(edge => edge.Source == edge.Target ? 2 : 1)).Max()); }