Example #1
0
        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()));
        }
Example #2
0
        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));
            }
        }
Example #3
0
 public int GetMaxDegree()
 {
     return(_vertexEdgeDictionary.Select(x => x.Value.Sum(edge => edge.Source == edge.Target ? 2 : 1)).Max());
 }