Exemplo n.º 1
0
 public void Execute()
 {
     _newItemFilterBlock = new ItemFilterCommentBlock(_itemFilterScript)
     {
         Comment = string.Empty
     };
     if (_addAfterItemFilterBlock != null)
     {
         _itemFilterScript.ItemFilterBlocks.Insert(_itemFilterScript.ItemFilterBlocks.IndexOf(_addAfterItemFilterBlock) + 1, _newItemFilterBlock);
     }
     else
     {
         _itemFilterScript.ItemFilterBlocks.Add(_newItemFilterBlock);
     }
 }
Exemplo n.º 2
0
        // TODO: Private
        public string TranslateItemFilterCommentBlockToString(IItemFilterCommentBlock itemFilterCommentBlock)
        {
            // TODO: Tests
            // TODO: # Section: text?
            var commentWithHashes = string.Empty;

            // Add "# " to the beginning of each line of the comment before saving it
            foreach (var line in new LineReader(() => new StringReader(itemFilterCommentBlock.Comment)))
            {
                commentWithHashes += $"# {line.TrimStart(' ')}{Environment.NewLine}";
            }

            // Remove trailing newline
            return(commentWithHashes.TrimEnd('\r', '\n'));
        }