public override string ToString() { var builder = new StringBuilder(); var writer = new IndentingStringWriter(builder); WriteLayer(writer, this); return(builder.ToString()); }
private static void WriteLayer(IndentingStringWriter writer, QueryLayer layer, string prefix = null) { writer.WriteLine(prefix + nameof(QueryLayer) + "<" + layer.ResourceContext.ResourceType.Name + ">"); using (writer.Indent()) { if (layer.Include != null) { writer.WriteLine($"{nameof(Include)}: {layer.Include}"); } if (layer.Filter != null) { writer.WriteLine($"{nameof(Filter)}: {layer.Filter}"); } if (layer.Sort != null) { writer.WriteLine($"{nameof(Sort)}: {layer.Sort}"); } if (layer.Pagination != null) { writer.WriteLine($"{nameof(Pagination)}: {layer.Pagination}"); } if (!layer.Projection.IsNullOrEmpty()) { writer.WriteLine(nameof(Projection)); using (writer.Indent()) { foreach ((ResourceFieldAttribute field, QueryLayer nextLayer) in layer.Projection) { if (nextLayer == null) { writer.WriteLine(field.ToString()); } else { WriteLayer(writer, nextLayer, field.PublicName + ": "); } } } } } }