using System.Text; using System.Web.Mvc; using ApacSale.Web.MVC; using Newtonsoft.Json; namespace Now.Web.JsonNet { public abstract class JsonNetController : BaseController { /// /// Creates a object that serializes the specified object to JavaScript Object Notation (JSON). /// /// /// /// The JSON result object that serializes the specified object to JSON format. The result object that is prepared by this method is written to the response by the ASP.NET MVC framework when the object is executed. /// /// The JavaScript object graph to serialize. /// The Json.Net serialization settings protected internal JsonResult JsonNet(object data, JsonSerializerSettings settings = null) { return this.JsonNet(data, (string)null, (Encoding)null, JsonRequestBehavior.DenyGet, settings); } /// /// Creates a object that serializes the specified object to JavaScript Object Notation (JSON) format. /// /// /// /// The JSON result object that serializes the specified object to JSON format. /// /// The JavaScript object graph to serialize.The content type (MIME type). /// The Json.Net serialization settings protected internal JsonResult JsonNet(object data, string contentType, JsonSerializerSettings settings = null) { return this.JsonNet(data, contentType, (Encoding)null, JsonRequestBehavior.DenyGet, settings); } /// /// Creates a object that serializes the specified object to JavaScript Object Notation (JSON) format. /// /// /// /// The JSON result object that serializes the specified object to JSON format. /// /// The JavaScript object graph to serialize.The content type (MIME type).The content encoding. /// The Json.Net serialization settings protected internal virtual JsonResult JsonNet(object data, string contentType, Encoding contentEncoding, JsonSerializerSettings settings = null) { return this.JsonNet(data, contentType, contentEncoding, JsonRequestBehavior.DenyGet, settings); } /// /// Creates a object that serializes the specified object to JavaScript Object Notation (JSON) format using the specified JSON request behavior. /// /// /// /// The result object that serializes the specified object to JSON format. /// /// The JavaScript object graph to serialize.The JSON request behavior. /// The Json.Net serialization settings protected internal JsonResult JsonNet(object data, JsonRequestBehavior behavior, JsonSerializerSettings settings = null) { return this.JsonNet(data, (string)null, (Encoding)null, behavior, settings); } /// /// Creates a object that serializes the specified object to JavaScript Object Notation (JSON) format using the specified content type and JSON request behavior. /// /// /// /// The result object that serializes the specified object to JSON format. /// /// The JavaScript object graph to serialize.The content type (MIME type).The JSON request behavior /// The Json.Net serialization settings protected internal JsonResult JsonNet(object data, string contentType, JsonRequestBehavior behavior, JsonSerializerSettings settings = null) { return this.JsonNet(data, contentType, (Encoding)null, behavior, settings); } /// /// Creates a object that serializes the specified object to JavaScript Object Notation (JSON) format using the content type, content encoding, and the JSON request behavior. /// /// /// /// The result object that serializes the specified object to JSON format. /// /// The JavaScript object graph to serialize.The content type (MIME type).The content encoding.The JSON request behavior /// The Json.Net serialization settings protected internal virtual JsonResult JsonNet(object data, string contentType, Encoding contentEncoding, JsonRequestBehavior behavior, JsonSerializerSettings settings = null) { return settings != null ? new JsonNetResult(settings) { Data = data, ContentType = contentType, ContentEncoding = contentEncoding, JsonRequestBehavior = behavior } : new JsonNetResult { Data = data, ContentType = contentType, ContentEncoding = contentEncoding, JsonRequestBehavior = behavior }; } } }