Exemplo n.º 1
0
        public static T Bind <T>(this T query, Id instanceId) where T : Query
        {
            var queryType = query.GetType();
            var areaMap   = AreaMap.From(new[] { queryType });

            AreaTypeName.TryFrom(queryType.Name, out var areaType);
            var flowType        = areaMap.GetFlow(areaType);
            var subscriptionKey = FlowKey.From(flowType, instanceId);

            FlowContext.Bind(query, subscriptionKey);
            return(query);
        }
Exemplo n.º 2
0
        public static bool TryFrom(string value, AreaMap area, out FlowKey key)
        {
            var idIndex = value.IndexOf(Id.Separator);

            var typePart = idIndex == -1 ? value : value.Substring(0, idIndex);
            var idPart   = idIndex == -1 ? "" : value.Substring(idIndex + 1);

            key = AreaTypeName.TryFrom(typePart, out var typeKey) && area.TryGetFlow(typeKey, out var type)
        ? new FlowKey(type, Id.From(idPart))
        : null;

            return(key != null);
        }
Exemplo n.º 3
0
        IEnumerable <FlowKey> ReadResumeFlows(JArray json)
        {
            foreach (var typeItem in json)
            {
                if (typeItem is JArray multiInstance)
                {
                    var type = _context.Area.GetFlow(AreaTypeName.From(multiInstance[0].Value <string>()));

                    foreach (var idItem in multiInstance.Skip(1))
                    {
                        yield return(FlowKey.From(type, Id.From(idItem.Value <string>())));
                    }
                }
                else
                {
                    yield return(FlowKey.From(typeItem.Value <string>(), _context.Area));
                }
            }
        }
 internal static EventType ReadEventType(this EventStoreContext context, ResolvedEvent e) =>
 context.Area.Events.Get(AreaTypeName.From(e.Event.EventType));