Esempio n. 1
0
        public static EntryElement ToEntry(EventRecord evnt, string userHostName)
        {
            if (evnt == null || userHostName == null)
            {
                return(null);
            }

            var entry = new EntryElement();

            entry.SetTitle(String.Format("{0} #{1}", evnt.EventStreamId, evnt.EventNumber));

            entry.SetId(HostName.Combine(userHostName, "/streams/{0}/{1}", evnt.EventStreamId, evnt.EventNumber));
            entry.SetUpdated(evnt.TimeStamp);

            entry.SetAuthor(AtomSpecs.Author);
            entry.SetSummary(String.Format("Entry #{0}", evnt.EventNumber));

            entry.AddLink(HostName.Combine(userHostName, "/streams/{0}/{1}", evnt.EventStreamId, evnt.EventNumber), "edit", null);

            entry.AddLink(
                HostName.Combine(userHostName, "/streams/{0}/event/{1}?format=text", evnt.EventStreamId, evnt.EventNumber),
                null,
                ContentType.PlainText);
            entry.AddLink(
                HostName.Combine(userHostName, "/streams/{0}/event/{1}?format=json", evnt.EventStreamId, evnt.EventNumber),
                "alternate",
                ContentType.Json);
            entry.AddLink(
                HostName.Combine(userHostName, "/streams/{0}/event/{1}?format=xml", evnt.EventStreamId, evnt.EventNumber),
                "alternate",
                ContentType.Xml);

            return(entry);
        }
Esempio n. 2
0
        private static void SetEntryProperties(string stream, int eventNumber, DateTime timestamp, Uri requestedUrl, EntryElement entry)
        {
            var escapedStreamId = Uri.EscapeDataString(stream);

            entry.SetTitle(eventNumber + "@" + stream);
            entry.SetId(HostName.Combine(requestedUrl, "/streams/{0}/{1}", escapedStreamId, eventNumber));
            entry.SetUpdated(timestamp);
            entry.SetAuthor(AtomSpecs.Author);
            entry.AddLink("edit",
                          HostName.Combine(requestedUrl, "/streams/{0}/{1}", escapedStreamId, eventNumber));
            entry.AddLink("alternate",
                          HostName.Combine(requestedUrl, "/streams/{0}/{1}", escapedStreamId, eventNumber));
        }