public Task GetAll() { var name = GetStringQueryString("name", required: false); var start = GetStart(); var pageSize = GetPageSize(); DocumentsOperationContext context; using (ContextPool.AllocateOperationContext(out context)) using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream())) { TransformerDefinition[] transformerDefinitions; if (string.IsNullOrEmpty(name)) { transformerDefinitions = Database.TransformerStore .GetTransformers() .OrderBy(x => x.Name) .Skip(start) .Take(pageSize) .Select(x => x.Definition) .ToArray(); } else { var transformer = Database.TransformerStore.GetTransformer(name); if (transformer == null) { HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; return(Task.CompletedTask); } transformerDefinitions = new[] { transformer.Definition }; } writer.WriteStartArray(); var isFirst = true; foreach (var transformerDefinition in transformerDefinitions) { if (isFirst == false) { writer.WriteComma(); } isFirst = false; writer.WriteTransformerDefinition(context, transformerDefinition); } writer.WriteEndArray(); } return(Task.CompletedTask); }
public static void Export(BlittableJsonTextWriter writer, Transformer transformer, JsonOperationContext context) { writer.WriteTransformerDefinition(context, transformer.Definition); }