internal static void SetTableViewProperty(this TableViewProperty property, string propertyValue) { // SourceTableView=SORTING(Search Description) // ORDER(Ascending) // WHERE(No. 2=CONST(FOO), // Description=FILTER(<>'')); propertyValue = RemoveSurroundingSquareBrackets(propertyValue); property.Value.Key = GetTableViewSorting(ref propertyValue); property.Value.Order = GetTableViewOrder(ref propertyValue); property.Value.TableFilter.SetFromPropertyValue(ref propertyValue); }
public static void Write(this TableViewProperty property, bool isLastProperty, PropertiesStyle style, CSideWriter writer) { var requiresSquareBrackets = property.Value.TableFilter.Any(f => f.Value.Any(c => "{}".Contains(c))); var openingBracket = requiresSquareBrackets ? "[" : ""; var closingBracket = requiresSquareBrackets ? "]" : ""; var components = new List <string>(); if (!string.IsNullOrEmpty(property.Value.Key)) { components.Add(string.Format("SORTING({0})", property.Value.Key)); } if (property.Value.Order.HasValue) { components.Add(string.Format("ORDER({0})", property.Value.Order)); } if (property.Value.TableFilter.Any()) { components.AddRange(property.Value.TableFilter.AsStrings()); } writer.Write("{0}={1}", property.Name, openingBracket); writer.Indent(writer.Column); foreach (var component in components) { var isLastComponent = (component == components.Last()); switch (isLastProperty && isLastComponent) { case true: writer.Write("{0}{1} ", component, closingBracket); break; case false: writer.Write(component); writer.WriteLineIf(isLastComponent, $"{closingBracket};"); writer.WriteLineIf(!isLastComponent, string.Empty); break; } } writer.Unindent(); }