static MyContext BuildContextOnTheFly(ImmutableEnvelope envelope, ImmutableMessage item)
        {
            var messageId = string.Format("[{0}]-{1}", envelope.EnvelopeId, item.Index);
            var token     = envelope.GetAttribute("token", "");

            return(new MyContext(messageId, token, envelope.CreatedOnUtc));
        }
 public ImmutableEnvelope(string envelopeId, ImmutableAttribute[] attributes, ImmutableMessage[] items,
     DateTime deliverOnUtc, DateTime createdOnUtc)
 {
     EnvelopeId = envelopeId;
     DeliverOnUtc = deliverOnUtc;
     _attributes = attributes;
     Items = items;
     CreatedOnUtc = createdOnUtc;
 }
        public static Color GetBackgroundColorForContract(ImmutableMessage message)
        {
            var commad = message.Content as IRecipeCommand;

            if (commad != null)
            {
                return CommonColors.Green;
            }

            var @event = message.Content as IRecipeEvent;

            if (@event != null)
            {
                return CommonColors.Blue;
            }
            return CommonColors.Gray;
        }
        public static Color GetBackgroundColorForContract(ImmutableMessage message)
        {
            var commad = message.Content as ICommand;

            if (commad != null)
            {
                return CommonColors.Green;
            }

            var @event = message.Content as IEvent;

            if (@event != null)
            {
                //if (@event is PollingApiForForecastsTimedOut)
                //{
                //    return CommonColors.Red;
                //}

                return CommonColors.Blue;
            }
            return CommonColors.Gray;
        }
        public static string GetCategoryNames(ImmutableMessage messages)
        {
            var item = messages.Content;

            if (item is IFunctionalCommand || item is IFunctionalEvent)
                return "system";

            var @event = item as IEvent<IIdentity>;

            if (@event != null)
            {
                return @event.Id.ToString();
            }

            var command = item as ICommand<IIdentity>;

            if (command != null)
            {
                return command.Id.ToString();
            }

            throw new InvalidOperationException("Unknown envelope category name.");
        }