public ParsedTopic(TopicPropertyCollection properties, TopicRevisionCollection topicLinks, ExternalReferencesMap externalReferences) { _properties.AddRange(properties); _topicLinks.AddRange(topicLinks); _externalReferences.AddRange(externalReferences); }
public bool HasProperty(string propertyName) { if (!_haveProperties) { _properties = Federation.GetTopicProperties(TopicRevision); _haveProperties = true; } if (_properties == null) { return false; } return _properties.Contains(propertyName); }
private static void ParseSingleLineProperties(string text, TopicPropertyCollection properties) { Regex propertyPattern = new Regex(c_propertyPattern, RegexOptions.Multiline); foreach (Match match in propertyPattern.Matches(text)) { string name = match.Groups["name"].Value; string rawValue = match.Groups["val"].Value.Trim(); TopicProperty topicProperty = null; if (!properties.Contains(name)) { topicProperty = new TopicProperty(name); properties.Add(topicProperty); } else { topicProperty = properties[name]; } TopicPropertyValue value = new TopicPropertyValue(rawValue); topicProperty.Values.Add(value); } }
private static TopicPropertyCollection ParseProperties(string text) { TopicPropertyCollection properties = new TopicPropertyCollection(); ParseSingleLineProperties(text, properties); ParseMultiLineProperties(text, properties); return properties; }
private static void ParseMultiLineProperties(string text, TopicPropertyCollection properties) { string[] lines = text.Split('\n'); Regex propertyPattern = s_multilinePropertyRegex; bool inMultilineProperty = false; string currentProperty = null; string endDelimiter = null; StringBuilder rawValueBuilder = new StringBuilder(); foreach (string line in lines) { if (inMultilineProperty) { if (endDelimiter != null && line.Trim() == endDelimiter) { inMultilineProperty = false; TopicProperty property = new TopicProperty(currentProperty); property.Values.Add(new TopicPropertyValue(rawValueBuilder.ToString())); properties.Add(property); } else { rawValueBuilder.Append(line); rawValueBuilder.Append("\n"); } } else { Match match = propertyPattern.Match(line); if (match.Success) { inMultilineProperty = true; currentProperty = match.Groups["name"].Value; string delimiter = match.Groups["delim"].Value; switch (delimiter) { case "[": endDelimiter = "]"; break; case "{": endDelimiter = "}"; break; default: endDelimiter = null; break; } string rawValue = match.Groups["val"].Value.Trim(); rawValueBuilder.Length = 0; rawValueBuilder.Append(rawValue); } } } }