private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, bool source) { try { var phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); var phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); var cont = item.NextSibling != null ? item.NextSibling.Value : string.Empty; phTagProperties.SegmentationHint = SegmentationHint.IncludeWithText; phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = item.Name; phTagProperties.CanHide = false; //determine tag id if (source) { _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; } return(phTag); } catch (Exception ex) { Log.Logger.Error($"CreatePhTag method: {ex.Message}\n {ex.StackTrace}"); } return(null); }
public IAbstractMarkupData CreatePlaceholder(string tagId, string tagContent) { // Dev Notes: the tagContent is switched with the Display text to align with how the tags are // recreated by the XLIFF 1.2 parser from the framework var textProperties = PropertiesFactory.CreatePlaceholderTagProperties("<ph id=\"" + tagId + "\"/>"); textProperties.DisplayText = tagContent; textProperties.SetMetaData("localName", "ph"); textProperties.SetMetaData("displayText", tagContent); textProperties.SetMetaData("attribute:id", tagId); if (ExistingTagIds.Contains(textProperties.TagId.Id)) { textProperties.TagId = !ExistingTagIds.Contains(tagId) ? new TagId(tagId) : new TagId(GetUniqueTagPairId()); } if (!ExistingTagIds.Contains(textProperties.TagId.Id)) { ExistingTagIds.Add(textProperties.TagId.Id); } return(ItemFactory.CreatePlaceholderTag(textProperties)); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); string cont; if (item.NextSibling == null) { cont = ""; } else { cont = item.NextSibling.Value; } phTagProperties.SegmentationHint = SegmentationHint.IncludeWithText; phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = item.Name; phTagProperties.CanHide = false; //determine tag id if (source) { /*Sdl.FileTypeSupport.Framework.NativeApi.TagId thisId = * new Sdl.FileTypeSupport.Framework.NativeApi.TagId(totalTagCount.ToString()); * * phTagProperties.TagId = thisId;*/ totalTagCount += 1; tmpTotalTagCount += 1; srcSegmentTagCount += 1; } else { /*foreach (object tag in thisSrcSegment.AllSubItems) * { * if (tag.ToString().StartsWith("<") && tag.ToString().EndsWith(">")) * { * IPlaceholderTag srcPh = (IPlaceholderTag)tag; * * if (srcPh.TagProperties.TagId.ToString() == totalTagCount.ToString()) * { * if (phTagProperties.TagContent == srcPh.TagProperties.TagContent) * { * Sdl.FileTypeSupport.Framework.NativeApi.TagId thisId = * new Sdl.FileTypeSupport.Framework.NativeApi.TagId(totalTagCount.ToString()); * * phTagProperties.TagId = thisId; * totalTagCount += 1; * } * } * } * }*/ } return(phTag); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, int tagNo, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = string.Format("{{{0}}}", tagNo); phTagProperties.CanHide = false; //determine tag id if (source) { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; } else { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; } return(phTag); }
private IPlaceholderTag CreatePhTag(string tagContent, int tagNo, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); phTagProperties.TagContent = tagContent; phTagProperties.DisplayText = string.Format("{{{0}}}", tagNo); phTagProperties.CanHide = false; if (source) { var thisId = new TagId(totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; if (tags.ContainsKey(int.Parse(thisId.Id)) && !tags.ContainsValue(phTagProperties)) { totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } if (!(tags.ContainsKey(int.Parse(thisId.Id)) && tags.ContainsValue(phTagProperties))) { tags.Add(totalTagCount, phTagProperties); } tagIds.Enqueue(totalTagCount); totalTagCount++; } else { int id; if (tagIds.Count != 0) { id = tagIds.Dequeue(); } else { id = totalTagCount++; } var thisId = new TagId(id.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; if (tags.ContainsKey(int.Parse(thisId.Id)) && !tags.ContainsValue(phTagProperties)) { totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } } return(phTag); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, int tagNo, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = string.Format("{{{0}}}", tagNo); phTagProperties.CanHide = false; //determine tag id if (source) { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; //check for source with the same Id and different properties if (CheckForIdAndPropertiesNotEqual(thisId, phTagProperties)) { _totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } //check for source with the same Id and same properties if (!CheckForIdAndPropertiesEqual(thisId, phTagProperties)) { _dictionaryTags.Add(int.Parse(thisId.Id), phTagProperties); } } else { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; if (CheckForIdAndPropertiesNotEqual(thisId, phTagProperties)) { _totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } } return(phTag); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, bool source) { var phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); var phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); var cont = item.NextSibling != null ? item.NextSibling.Value : string.Empty; phTagProperties.SegmentationHint = SegmentationHint.IncludeWithText; phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = item.Name; phTagProperties.CanHide = false; //determine tag id if (source) { _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; } return(phTag); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, int tagNo) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); string cont; if (item.NextSibling == null) { cont = ""; } else { cont = item.NextSibling.Value; } phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = item.Name; phTagProperties.CanHide = false; return(phTag); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); string cont; if (item.NextSibling == null) { cont = ""; } else { cont = item.NextSibling.Value; } phTagProperties.SegmentationHint = SegmentationHint.IncludeWithText; phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = item.Name; phTagProperties.CanHide = false; //determine tag id if (source) { /*Sdl.FileTypeSupport.Framework.NativeApi.TagId thisId = * new Sdl.FileTypeSupport.Framework.NativeApi.TagId(totalTagCount.ToString()); * * phTagProperties.TagId = thisId;*/ totalTagCount += 1; tmpTotalTagCount += 1; srcSegmentTagCount += 1; } return(phTag); }