public void Write(string mimeType, T resource) { var view = _factory.GetView(); view.Page.ServiceLocator = _services; view.Render(); _writer.ContentType(MimeType.Html); }
protected override DoNext performInvoke() { var view = _factory.GetView(); view.Page.ServiceLocator = _services; view.Render(); _writer.ContentType(MimeType.Html); return(DoNext.Continue); }
public bool WriteData(object data, string id = null, string @event = null, int?retry = null) { if (_first) { _writer.ContentType(MimeType.EventStream); _first = false; } var builder = new StringBuilder(); if (@event.IsNotEmpty()) { builder.Append(Id); builder.Append(id); builder.Append("/"); builder.Append(@event); builder.Append("\n"); } else { writeProp(builder, Id, id); } writeProp(builder, Retry, retry); writeProp(builder, Data, data); builder.Append("\n"); _writer.Write(builder.ToString()); try { _writer.Flush(); return(true); } // It is possible to receive this exception if the client connection has been lost. catch (HttpException) { return(false); } // Another connectivity issue catch (AccessViolationException) { return(false); } }