Source/NFX.Wave/Handlers/MVCHandler.cs
/// <summary>
/// Turns result object into appropriate response
/// </summary>
Turns result object into appropriate response
Turns result object into appropriate response
protected virtual void ProcessResult(Controller controller, WorkContext work, object result)
      {
        if (result==null) return;
        if (result is string)
        {
          work.Response.ContentType = ContentType.TEXT;
          work.Response.Write(result);
          return;
        }
        if (result is WaveTemplate)
        {
          ((WaveTemplate)result).Render(work, null);
          return;
        }
        if (result is Image)
        {
          var img = (Image)result;
          work.Response.ContentType = ContentType.PNG;
          img.Save(work.Response.GetDirectOutputStreamForWriting(), System.Drawing.Imaging.ImageFormat.Png);
          return;
        }
        if (result is IActionResult)
        {
          ((IActionResult)result).Execute(controller, work);
          return;
        }
        work.Response.WriteJSON(result, JSONWritingOptions.CompactRowsAsMap ); 
      }
protected virtual void ProcessResult ( Controller controller , WorkContext work , object result ) { if ( result == null ) return ; if ( result is string ) { work . Response . ContentType = ContentType . TEXT ; work . Response . Write ( result ) ; return ; } if ( result is WaveTemplate ) { ( ( WaveTemplate ) result ) . Render ( work , null ) ; return ; } if ( result is Image ) { var img = ( Image ) result ; work . Response . ContentType = ContentType . PNG ; img . Save ( work . Response . GetDirectOutputStreamForWriting ( ) , System . Drawing . Imaging . ImageFormat . Png ) ; return ; } if ( result is IActionResult ) { ( ( IActionResult ) result ) . Execute ( controller , work ) ; return ; } work . Response . WriteJSON ( result , JSONWritingOptions . CompactRowsAsMap ) ; }
Turns result object into appropriate response
Turns result object into appropriate response
//default serialize object as JSON
controller
Controller
work
WorkContext
result
object