public void RESTfullUrlReturnTypeIsSetToXML() { string url = "http://foo.com/services/data/product/list.xml"; RESTfullUrl me = new RESTfullUrl(url); Assert.AreEqual(url, (string)(new Reflector(me).GetField("_rawUrl"))); Assert.AreEqual(RESTReturnType.xml, me.ReturnType); }
public void Setup() { handler = new RESTHandler(); reflect = new Reflector(handler); currentUrl = new RESTfullUrl("http://foo.com/services/data/product/list.json"); reflect.SetField("_url", currentUrl); }
/// <summary> /// Main entry point /// </summary> /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param> public void ProcessRequest(HttpContext context) { _context = context; _outputWriter = context.Response.Output; //parse the URL _url = new RESTfullUrl(context); DataSet ds = GenerateReturnSet(); _output = FormatOutput(ds); RenderOutput(); }
/// <summary> /// Main entry point /// </summary> /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param> public void ProcessRequest(HttpContext context) { _context = context; _outputWriter = context.Response.Output; //parse the URL _url = new RESTfullUrl(context); DataSet ds; RestProvider provider = RestService.GetInstance(Enum.GetName(typeof(RESTReturnType),_url.ReturnType)); if (!CodeService.ShouldGenerate(_url.TableName, provider.AllowedTables, new string[] { }, DataService.Provider) && !CodeService.ShouldGenerate(_url.SpName, provider.AllowedTables, new string[] { }, DataService.Provider)) ds = new DataSet(); else ds = GenerateReturnSet(); _output = FormatOutput(ds); RenderOutput(); }
public RESTfullContent ConvertOutputToEndFormat(string result, RESTfullUrl url) { RESTfullContent r; switch (url.ReturnType) { case RESTReturnType.json: XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(result); //convert XML to a JSON string string json = XmlToJSONParser.XmlToJSON(xdoc); //clean up and prep for delivery json = json.Replace(@"\", @"\\"); //final clean up and make it safe json for client side //removed the extra call to SafeJSON //r = new RESTfullContent(XmlToJSONParser.SafeJSON(json), "text/json"); //see http://forums.subsonicproject.com/t/3391.aspx for details r = new RESTfullContent(json, "text/json"); break; //data should already be in xml format case RESTReturnType.xml: default: r = new RESTfullContent(result, "text/xml"); break; } return r; }
public void TearDown() { handler = null; reflect = null; currentUrl = null; }