Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nick Berardi
committed
Apr 18, 2011
1 parent
0ed9886
commit 12a5e79
Showing
7 changed files
with
75 additions
and
105 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,60 @@ | ||
using System; | ||
using ManagedFusion.Web.Mvc; | ||
using System.Web.Mvc; | ||
|
||
namespace ManagedFusion.Web.Mvc | ||
{ | ||
public class AutoSerializedView : SerializedView | ||
{ | ||
public AutoSerializedView() | ||
{ | ||
StatusCode = 200; | ||
StatusDescription = "OK"; | ||
} | ||
|
||
public override void Render(System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) | ||
{ | ||
var focus = (IView)null; | ||
|
||
ResponseType responseType = ResponseType.None; | ||
var routeData = viewContext.RouteData.Values; | ||
|
||
object tempObj; | ||
if (routeData.TryGetValue("responseType", out tempObj) && tempObj is ResponseType) | ||
responseType = (ResponseType)tempObj; | ||
|
||
if (responseType == ResponseType.None) | ||
responseType = ServiceHelper.GetResponseType(viewContext); | ||
|
||
switch (responseType) | ||
{ | ||
case ResponseType.JavaScript: | ||
focus = new JavaScriptCallbackResult(); | ||
break; | ||
|
||
case ResponseType.Json: | ||
focus = new JsonView(); | ||
break; | ||
|
||
case ResponseType.Xml: | ||
focus = new XmlView(); | ||
break; | ||
|
||
case ResponseType.Csv: | ||
focus = new CsvResult(); | ||
break; | ||
|
||
case ResponseType.Html: | ||
default: | ||
focus = viewContext.View; | ||
break; | ||
} | ||
|
||
if (focus is SerializedView) | ||
ServiceHelper.CopyProperties(this, (SerializedView)focus); | ||
|
||
if (focus != null) | ||
focus.Render(viewContext, writer); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters