private void RenderEntity(HttpContext httpContext, object query, Entity entity) { var context = new RenderContext { PaperRendererRegistry = registry, Injector = injector, HttpContext = httpContext, PathTemplate = PathTemplate, Entity = entity, Query = query, PathArgs = UriUtil.GetPathArgs(httpContext, PathTemplate), QueryArgs = UriUtil.GetQueryArgs(httpContext) }; var args = new object[] { context }; // Atribuindo parametros do objeto foreach (var method in SetChain) { method.Invoke(null, args); } // Capturando dados var data = query.Call("GetData"); var rows = query.Call("GetRows"); if (data is IEnumerable) { data = ((IEnumerable)data).Cast <object>().ToArray(); } if (rows is IEnumerable) { rows = ((IEnumerable)rows).Cast <object>().ToArray(); } context.Data = data; context.Rows = rows; // Renderizando e pós-renderizando o objeto foreach (var method in RenderingChain) { method.Invoke(null, args); } }