示例#1
0
文件: CLI.cs 项目: blankego/cccount
        void DoJob()
        {
            _counter = new Counter ();

            if (_files.Count == 0)//get input from stdin
            {
                using (var sr = new StreamReader (Console.OpenStandardInput (), input_encoding))
                {
                    _counter.Process (sr);
                }
            }
            else
            {
                WalkFileEntries (_files, f =>
                {
                    if (string.IsNullOrEmpty (extension) || f.EndsWith ("." + extension))
                    {
                        using(var sr = new StreamReader(f,input_encoding))
                        {
                            _counter.Process (sr);
                        }
                    }
                });
            }
        }
        public void VisitText(IText text)
        {
            var fragments = new Queue <IFragment>(_textProcessor.Process(text.Properties.Text));

            while (fragments.Count > 0)
            {
                var fragment = fragments.Dequeue();

                switch (fragment.InlineType)
                {
                case InlineType.Text:
                    _currentContainer.Add(CreateText(fragment.Content));
                    break;

                case InlineType.Placeholder:
                    _currentContainer.Add(CreatePlaceholder(fragment.Content, fragment.SegmentationHint));
                    break;

                case InlineType.StartTag:
                    _currentContainer.Add(CreateTags(fragment, fragments));
                    break;

                case InlineType.EndTag:
                    throw new ArgumentOutOfRangeException();

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
        public void VisitText_WhenTextIsTextInlineType_ShouldAddText()
        {
            // Arrange
            var testee = CreateTestee();

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

            var textPropertiesMock = A.Fake <ITextProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreateTextProperties("text")).Returns(textPropertiesMock);

            var newTextMock = A.Fake <IText>();

            A.CallTo(() => _itemFactoryMock.CreateText(textPropertiesMock)).Returns(newTextMock);

            // Act
            testee.VisitText(_textMock);

            // Assert
            A.CallTo(() => _sourceParagraphMock.Add(newTextMock)).MustHaveHappened();
        }
示例#4
0
        public string Process(string text)
        {
            List <TextBlock> blocks = SplitText(text);

            blocks.ForEach(block => block.text = block.isMatch ? ProcessText(block.text) : textProcessor.Process(block.text));
            return(blocks.Aggregate(string.Empty, (first, second) => first + second.text));
        }
示例#5
0
 public override string Get(string key)
 {
     return(_textProcessor.Process(Resources.ResourceManager.GetString(key) ?? _missingTextProvider.Get(key)));
 }
示例#6
0
        /// <inheritdoc />
        public void Set(string key, string value)
        {
            var processedValue = TextProcessor.Process(value);

            Store.AddOrUpdate(key, processedValue, (k, v) => processedValue);
        }
示例#7
0
        /// <inheritdoc />
        public void Set(string key, string value)
        {
            var processedValue = TextProcessor.Process(value);

            Repository.Set(key, processedValue);
        }