public LabelExpression Parse(string expression, int lineCounter) { this.lineCounter = lineCounter; LabelExpression labelExpression = new LabelExpression(); string[] splits = expression.Split(separators, StringSplitOptions.RemoveEmptyEntries); foreach (string split in splits) { string elementDef = split.Trim(); // skip empty splits if (elementDef.Length == 0) { continue; } Match match = elementRegex.Match(elementDef); if (false == match.Success) { ThrowParseError("Syntax error in label '{0}'", split); } string keyValue = match.Groups["key"].Value; string stringValue = match.Groups["string"].Value; ILabelExpressionElement labelExpressionElement = null; if (false == String.IsNullOrEmpty(keyValue)) { if (false == String.IsNullOrEmpty(stringValue)) { labelExpressionElement = new OsmKeyLabelExpressionElement(keyValue, stringValue); } else { labelExpressionElement = new OsmKeyLabelExpressionElement(keyValue); } } else { labelExpressionElement = new FormatLabelExpressionElement(stringValue); } labelExpression.AddElement(labelExpressionElement); } return(labelExpression); }
public OsmKeyLabelExpressionElement(string keyName, string conditionalFormat) { this.keyName = keyName; conditionalElement = new FormatLabelExpressionElement(conditionalFormat); }