本文整理汇总了C#中Segment.GetTagCount方法的典型用法代码示例。如果您正苦于以下问题:C# Segment.GetTagCount方法的具体用法?C# Segment.GetTagCount怎么用?C# Segment.GetTagCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment.GetTagCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveTrailingClosingTags
/// <summary>
/// Microsoft always adds closing tags, but we don't keep track of our tags that way..so the segments always have garbage text at the end with the closing tag markup...this method removes them
/// </summary>
/// <param name="segment"></param>
/// <returns></returns>
public Segment RemoveTrailingClosingTags(Segment segment)
{
#region RemoveTrailingClosingTags
SegmentElement element = segment.Elements[segment.Elements.Count - 1]; //get last element
string str = element.ToString();
int tagsCount = segment.GetTagCount();
string pattern = @"\</tg[0-9]*\>"; //we want to find "</tg" + {any number} + ">"
Regex rgx = new Regex(pattern);
System.Type elType = element.GetType();
MatchCollection matches = rgx.Matches(str);
if (elType.ToString().Equals("Sdl.LanguagePlatform.Core.Text") && matches.Count > 0) //if a text element containing matches
{
foreach (Match myMatch in matches)
{
str = str.Replace(myMatch.Value, ""); //puts our separator around tagtexts
}
segment.Elements.Remove(element);
segment.Add(str.TrimStart());
}
#endregion
return segment;
}