SmartFormat() public static method

public static SmartFormat ( EventStore.Core.Data.ResolvedEvent evnt, ICodec targetCodec ) : object
evnt EventStore.Core.Data.ResolvedEvent
targetCodec ICodec
return object
Esempio n. 1
0
        public static string EventEntry(HttpResponseFormatterArgs entity, Message message, EmbedLevel embed)
        {
            var msg = message as ClientMessage.ReadEventCompleted;

            if (msg == null || msg.Result != ReadEventResult.Success || msg.Record.Event == null)
            {
                return(entity.ResponseCodec.To(new {}));
            }

            switch (entity.ResponseCodec.ContentType)
            {
            case ContentType.Atom:
            case ContentType.AtomJson:
            case ContentType.Html:
                return(entity.ResponseCodec.To(Convert.ToEntry(msg.Record, entity.RequestedUrl, embed, singleEntry: true)));

            default:
                return(AutoEventConverter.SmartFormat(msg.Record, entity.ResponseCodec));
            }
        }
Esempio n. 2
0
        public static string ReadEventCompleted(HttpEntity entity, Message message)
        {
            Debug.Assert(message.GetType() == typeof(ClientMessage.ReadEventCompleted));

            var completed = message as ClientMessage.ReadEventCompleted;

            if (completed != null)
            {
                switch (completed.Result)
                {
                case SingleReadResult.Success:
                    return(AutoEventConverter.SmartFormat(completed, entity.ResponseCodec));

                case SingleReadResult.NotFound:
                case SingleReadResult.NoStream:
                case SingleReadResult.StreamDeleted:
                    return(string.Empty);

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            return(string.Empty);
        }