protected internal static void RenderEachTable(IWebRenderer renderer, DaoProxyRegistration daoProxyReg) { Assembly currentAssembly = daoProxyReg.Assembly; Type[] tableTypes = currentAssembly.GetTypes().Where(type => type.HasCustomAttributeOfType <TableAttribute>()).ToArray(); tableTypes.Each(type => { renderer.Render(type.Construct()); }); }
// ** Retrieve / GET ** // /{Type}.{ext}?{Query} // /{Type}/{Id}.{ext} // /{Type}/{Id}/{ChildListProperty}.{ext} protected override bool Get(IHttpContext context) { RestRequest restRequest = new RestRequest(context); bool result = false; if (restRequest.IsValid) { IResponse response = context.Response; Type type = restRequest.GetStorableType(Repository.StorableTypes); if (type != null) { IWebRenderer renderer = RendererFactory.CreateRenderer(context.Request, restRequest.Extension); if (restRequest.Query.Count > 0) { renderer.Render(new RestResponse { Success = true, Data = Repository.Query(type, restRequest.Query) }, response.OutputStream); result = true; } else if (restRequest.Id > 0) { object instance = Repository.Retrieve(type, restRequest.Id); if (instance != null) { RestResponse restResponse = new RestResponse { Success = true, Data = instance }; if (!string.IsNullOrEmpty(restRequest.ChildListProperty)) { restResponse.Data = instance.Property(restRequest.ChildListProperty); } renderer.Render(restResponse, response.OutputStream); result = true; } } } } return(result); }