/// <summary> /// Handles markup extension value in style as: /// XyzAttribute="{XyzMarkup value1, /// value2, /// key1=value1, /// key2=value2}" /// </summary> /// <param name="attrInfo"></param> /// <param name="baseIndentationString"></param> /// <returns></returns> public string ToMultiLineString(AttributeInfo attrInfo, string baseIndentationString) { #region Parameter Checks if (!attrInfo.IsMarkupExtension) { throw new ArgumentException("AttributeInfo shall have a markup extension value.", MethodBase.GetCurrentMethod().GetParameters()[0].Name); } #endregion Parameter Checks if (attrInfo.IsMarkupExtension) { string currentIndentationString = baseIndentationString + string.Empty.PadLeft(attrInfo.Name.Length + 2, ' '); var lines = _formatter.Format(attrInfo.MarkupExtension); var buffer = new StringBuilder(); buffer.AppendFormat("{0}=\"{1}", attrInfo.Name, lines.First()); foreach (var line in lines.Skip(1)) { buffer.AppendLine(); buffer.Append(_indentService.Normalize(currentIndentationString + line)); } buffer.Append('"'); return buffer.ToString(); } return $"{attrInfo.Name}=\"{attrInfo.Value}\""; }
/// <summary> /// Single line value line in style as: /// attribute_name="attribute_value" /// </summary> /// <param name="attrInfo"></param> /// <returns></returns> public string ToSingleLineString(AttributeInfo attrInfo) { var valuePart = attrInfo.IsMarkupExtension ? _formatter.FormatSingleLine(attrInfo.MarkupExtension) : attrInfo.Value.ToXmlEncodedString(); return $"{attrInfo.Name}=\"{valuePart}\""; }
private int AttributeInfoComparison(AttributeInfo x, AttributeInfo y) { if (x.OrderRule.Group != y.OrderRule.Group) { return x.OrderRule.Group.CompareTo(y.OrderRule.Group); } if (x.OrderRule.Priority != y.OrderRule.Priority) { return x.OrderRule.Priority.CompareTo(y.OrderRule.Priority); } return _options.OrderAttributesByName ? string.Compare(x.Name, y.Name, StringComparison.Ordinal) : 0; }