Пример #1
0
        private void AddPlaceholderTag(ICollection <IAbstractMarkupData> segmentContent, IText text)
        {
            var processedData = Anonymizer(text.Properties.Text, false);
            var tag           = _factory.CreatePlaceholderTag(_propertiesFactory.CreatePlaceholderTagProperties(processedData));

            tag.Properties.SetMetaData("Anonymizer", "Anonymizer");

            segmentContent.Add(tag);
        }
        private IAbstractMarkupData CreatePlaceholder(string chunk)
        {
            var tag     = $"<{chunk}/>";
            var phProps = itemFactory.PropertiesFactory.CreatePlaceholderTagProperties(tag);

            phProps.TextEquivalent = chunk;
            phProps.TagContent     = tag;

            return(itemFactory.CreatePlaceholderTag(phProps));
        }
        private IPlaceholderTag CreatePlaceholder(string content, SegmentationHint segmentationHint)
        {
            var placeholderProperties = _propertiesFactory.CreatePlaceholderTagProperties(content);

            placeholderProperties.TagContent       = content;
            placeholderProperties.DisplayText      = content;
            placeholderProperties.SegmentationHint = segmentationHint;

            return(_itemFactory.CreatePlaceholderTag(placeholderProperties));
        }
Пример #4
0
        public IAbstractMarkupData CreatePlaceholder(string tagId, string text)
        {
            var textProperties = _propertiesFactory.CreatePlaceholderTagProperties(text);

            //if (!string.IsNullOrEmpty(tagId))
            //{
            //	textProperties.TagId = new TagId(tagId);
            //}

            return(_factory.CreatePlaceholderTag(textProperties));
        }
        public void VisitText_WhenTextIsPlaceholderInlineType_ShouldAddPlaceholder()
        {
            // Arrange
            var testee = CreateTestee();

            A.CallTo(() => _textProcessorMock.Process(TexBeforeProcessing)).Returns(new List <IFragment>
            {
                new Fragment(InlineType.Placeholder, "{0}")
            });

            var placeholderTagPropertiesMock = A.Fake <IPlaceholderTagProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreatePlaceholderTagProperties("{0}")).Returns(placeholderTagPropertiesMock);

            var newPlactholderMock = A.Fake <IPlaceholderTag>();

            A.CallTo(() => _itemFactoryMock.CreatePlaceholderTag(placeholderTagPropertiesMock)).Returns(newPlactholderMock);

            // Act
            testee.VisitText(_textMock);

            // Assert
            A.CallTo(() => _sourceParagraphMock.Add(newPlactholderMock)).MustHaveHappened();
        }
Пример #6
0
        private IAbstractMarkupData CreatePlaceholderTag(ContentMatch match)
        {
            var placeholderProps = _itemFactory.PropertiesFactory.CreatePlaceholderTagProperties(match.Value);


            placeholderProps.CanHide     = match.MatchRule.CanHide;
            placeholderProps.IsSoftBreak = match.MatchRule.IsSoftBreak;
            placeholderProps.IsWordStop  = match.MatchRule.IsWordStop;

            placeholderProps.DisplayText      = GetDisplayName(match.Value);
            placeholderProps.SegmentationHint = match.MatchRule.SegmentationHint;
            placeholderProps.TagContent       = match.Value;

            if (!string.IsNullOrEmpty(match.MatchRule.TextEquivalent))
            {
                placeholderProps.TextEquivalent = match.MatchRule.TextEquivalent;
            }
            placeholderProps.SetMetaData(EmbeddedContentMetaKey, match.Value);

            return(_itemFactory.CreatePlaceholderTag(placeholderProps));
        }
Пример #7
0
        public IAbstractMarkupData CreatePlaceholder(string tagId, string text)
        {
            var textProperties = _propertiesFactory.CreatePlaceholderTagProperties(text);

            if (ExistingPlaceholderIds.Contains(textProperties.TagId.Id))
            {
                if (!ExistingPlaceholderIds.Contains(tagId))
                {
                    textProperties.TagId = new TagId(tagId);
                }
                else
                {
                    textProperties.TagId = new TagId(GetUniqueTagPairId());
                }
            }

            if (!ExistingPlaceholderIds.Contains(textProperties.TagId.Id))
            {
                ExistingPlaceholderIds.Add(textProperties.TagId.Id);
            }

            return(_factory.CreatePlaceholderTag(textProperties));
        }
Пример #8
0
        private void AddPlaceholderTag(ICollection <IAbstractMarkupData> segmentContent, IText text, List <AnonymizedData> anonymizedDataList)
        {
            var currentData = anonymizedDataList?.FirstOrDefault(ad => ad.MatchText == text.Properties.Text);

            var processedData = text.Properties.Text;

            if (currentData?.EncryptedText != null)
            {
                processedData = currentData.EncryptedText;
            }

            if (processedData == null)
            {
                return;
            }

            var tag = _documentItemFactory.CreatePlaceholderTag(
                _propertiesFactory.CreatePlaceholderTagProperties(processedData));

            tag.Properties.SetMetaData("Anonymizer", "Anonymizer");

            segmentContent.Add(tag);
        }
Пример #9
0
        private void GetSubsegmentPi(IText segmentText, List <IAbstractMarkupData> segmentContent, List <AnonymizedData> anonymizedDataList)
        {
            //this means we have PI data + text
            if (segmentText.Properties.Text.Length > anonymizedDataList[0].MatchText.Length)
            {
                //check if PI data is on first position split the segment after the PI
                if (anonymizedDataList[0].PositionInOriginalText.Equals(0))
                {
                    var remainingSegmentText = segmentText.Split(anonymizedDataList[0].MatchText.Length);

                    //check if we should encrypt or only tag the data
                    var processedData = Anonymizer(segmentText.Properties.Text, false);
                    var tag           = _factory.CreatePlaceholderTag(
                        _propertiesFactory.CreatePlaceholderTagProperties(processedData));
                    tag.Properties.SetMetaData("Anonymizer", "Anonymizer");
                    //Add encrypted tag to collection
                    segmentContent.Add(tag);

                    if (ShouldAnonymize(remainingSegmentText.Properties.Text))
                    {
                        var remainingData = GetAnonymizedData(remainingSegmentText.Properties.Text);
                        GetSubsegmentPi(remainingSegmentText, segmentContent, remainingData);
                    }
                    else
                    {
                        segmentContent.Add(remainingSegmentText);
                    }
                }
                else
                {
                    var remainingSegmentText = segmentText.Split(anonymizedDataList[0].PositionInOriginalText);
                    if (ShouldAnonymize(segmentText.Properties.Text))
                    {
                        var remainingData = GetAnonymizedData(segmentText.Properties.Text);
                        GetSubsegmentPi(segmentText, segmentContent, remainingData);
                    }
                    else
                    {
                        segmentContent.Add(segmentText);
                    }
                    if (ShouldAnonymize(remainingSegmentText.Properties.Text))
                    {
                        var remainingData = GetAnonymizedData(remainingSegmentText.Properties.Text);
                        GetSubsegmentPi(remainingSegmentText, segmentContent, remainingData);
                    }
                    else
                    {
                        var processedData = Anonymizer(remainingSegmentText.Properties.Text, false);
                        var tag           = _factory.CreatePlaceholderTag(
                            _propertiesFactory.CreatePlaceholderTagProperties(processedData));
                        tag.Properties.SetMetaData("Anonymizer", "Anonymizer");
                        segmentContent.Add(tag);
                    }
                }
            }             //segment contains only PI data
            else
            {
                var processedData = Anonymizer(segmentText.Properties.Text, false);
                var tag           = _factory.CreatePlaceholderTag(
                    _propertiesFactory.CreatePlaceholderTagProperties(processedData));

                tag.Properties.SetMetaData("Anonymizer", "Anonymizer");
                segmentContent.Add(tag);
            }
        }