public void ParseLengths_Accepts_Space_Separators() { var result = GridLength.ParseLengths("* Auto 2* 4").ToList(); Assert.Equal( new[] { new GridLength(1, GridUnitType.Star), GridLength.Auto, new GridLength(2, GridUnitType.Star), new GridLength(4, GridUnitType.Pixel), }, result); }
public void ParseLengths_Accepts_Comma_Separators_With_Spaces() { var result = GridLength.ParseLengths("*, Auto, 2* ,4", CultureInfo.InvariantCulture).ToList(); Assert.Equal( new[] { new GridLength(1, GridUnitType.Star), GridLength.Auto, new GridLength(2, GridUnitType.Star), new GridLength(4, GridUnitType.Pixel), }, result); }
private static bool ConvertDefinitionList( IXamlAstValueNode node, string text, AvaloniaXamlIlWellKnownTypes types, IXamlType listType, IXamlType elementType, string errorDisplayName, out IXamlAstValueNode result) { try { var lengths = GridLength.ParseLengths(text); var definitionTypeRef = new XamlAstClrTypeReference(node, elementType, false); var definitionConstructorGridLength = elementType.GetConstructor(new List <IXamlType> { types.GridLength }); IXamlAstValueNode CreateDefinitionNode(GridLength length) { var lengthNode = new AvaloniaXamlIlGridLengthAstNode(node, types, length); return(new XamlAstNewClrObjectNode(node, definitionTypeRef, definitionConstructorGridLength, new List <IXamlAstValueNode> { lengthNode })); } var definitionNodes = new List <IXamlAstValueNode>(lengths.Select(CreateDefinitionNode)); result = new AvaloniaXamlIlAvaloniaListConstantAstNode(node, types, listType, elementType, definitionNodes); return(true); } catch { throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a {errorDisplayName}", node); } }