コード例 #1
0
ファイル: ReplaceManager.cs プロジェクト: nice1378/mygui
        public void DoReplace(FileData _data, IReplacer[] _replacers)
        {
            for (int index = 0; index < _data.Data.Length; )
            {
                if ((_data.Data[index] == '#') && (index + 1 < _data.Data.Length) && (_data.Data[index + 1] == '{'))
                {
                    int endIndex = index + 1;
                    while (endIndex < _data.Data.Length)
                    {
                        if (_data.Data[endIndex] == '}')
                            break;
                        endIndex++;
                    }

                    if (endIndex < _data.Data.Length)
                    {
                        int count = endIndex - index + 1;
                        char[] destination = new char[count];
                        _data.Data.CopyTo(index, destination, 0, count);

                        _data.Data.Remove(index, count);
                        _data.Data.Insert(index, ReplaceTag(destination, _replacers));
                    }
                }
                else
                {
                    index++;
                }
            }
        }
コード例 #2
0
        public static AskReplacementWriter Create(
            ContentDisplayStyle contentDisplayStyle,
            string input,
            IReplacer replacer,
            Lazy <TextWriter>?lazyWriter,
            ContentWriterOptions options,
            MatchOutputInfo?outputInfo,
            bool isInteractive,
            SpellcheckState?spellcheckState = null)
        {
            switch (contentDisplayStyle)
            {
            case ContentDisplayStyle.Value:
            case ContentDisplayStyle.ValueDetail:
                return(new AskValueReplacementWriter(
                           input,
                           replacer,
                           lazyWriter,
                           options,
                           outputInfo,
                           isInteractive,
                           spellcheckState));

            case ContentDisplayStyle.Line:
                return(new AskLineReplacementWriter(input, replacer, lazyWriter, options, isInteractive, spellcheckState));

            case ContentDisplayStyle.UnmatchedLines:
            case ContentDisplayStyle.AllLines:
                throw new InvalidOperationException();

            default:
                throw new InvalidOperationException($"Unknown enum value '{contentDisplayStyle}'.");
            }
        }
コード例 #3
0
 public EnumerableOperation(IReplacer replacer, int bufferSize)
     : base(replacer)
 {
     this.bufferSize = bufferSize;
     this.firstNode = new BufferNode();
     this.lastNode = firstNode;
 }
コード例 #4
0
        public static ContentWriter CreateReplace(
            ContentDisplayStyle contentDisplayStyle,
            string input,
            IReplacer replacer,
            ContentWriterOptions options,
            TextWriter?textWriter           = null,
            MatchOutputInfo?outputInfo      = null,
            SpellcheckState?spellcheckState = null)
        {
            switch (contentDisplayStyle)
            {
            case ContentDisplayStyle.Value:
            case ContentDisplayStyle.ValueDetail:
                return(new ValueReplacementWriter(input, replacer, options, textWriter, outputInfo, spellcheckState));

            case ContentDisplayStyle.Line:
                return(new LineReplacementWriter(input, replacer, options, textWriter, spellcheckState));

            case ContentDisplayStyle.AllLines:
                return(new AllLinesReplacementWriter(input, replacer, options, textWriter, spellcheckState));

            case ContentDisplayStyle.UnmatchedLines:
                throw new NotSupportedException($"Value '{contentDisplayStyle}' is not supported.");

            default:
                throw new InvalidOperationException($"Unknown enum value '{contentDisplayStyle}'.");
            }
        }
コード例 #5
0
 public AskLineReplacementWriter(
     string input,
     IReplacer replacer,
     Lazy <TextWriter>?lazyWriter,
     ContentWriterOptions options,
     bool isInteractive,
     SpellcheckState?spellcheckState = null) : base(input, replacer, lazyWriter, options, isInteractive, spellcheckState)
 {
     MatchingLineCount = 0;
 }
コード例 #6
0
 private ContentWriter CreateReplacementWriter(
     ContentDisplayStyle contentDisplayStyle,
     string input,
     IReplacer replacer,
     ContentWriterOptions options,
     TextWriter?textWriter      = null,
     MatchOutputInfo?outputInfo = null)
 {
     return(ContentWriter.CreateReplace(contentDisplayStyle, input, replacer, options, textWriter, outputInfo, SpellcheckState));
 }
コード例 #7
0
 public Calculator(ISumCalculator sumCalculator,
                   IReplacer replacer,
                   IValidator validator,
                   INumbersExtractor numbersExtractor)
 {
     this.sumCalculator    = sumCalculator;
     this.replacer         = replacer;
     this.validator        = validator;
     this.numbersExtractor = numbersExtractor;
 }
コード例 #8
0
 public LineReplacementWriter(
     string input,
     IReplacer replacer,
     ContentWriterOptions options,
     TextWriter?textWriter           = null,
     SpellcheckState?spellcheckState = null) : base(input, options)
 {
     Replacer        = replacer;
     _textWriter     = textWriter;
     SpellcheckState = spellcheckState;
 }
コード例 #9
0
 public AskValueReplacementWriter(
     string input,
     IReplacer replacer,
     Lazy <TextWriter>?lazyWriter,
     ContentWriterOptions options,
     MatchOutputInfo?outputInfo,
     bool isInteractive,
     SpellcheckState?spellcheckState = null) : base(input, replacer, lazyWriter, options, isInteractive, spellcheckState)
 {
     OutputInfo = outputInfo;
 }
コード例 #10
0
ファイル: ReplaceManager.cs プロジェクト: nice1378/mygui
        private string ReplaceTag(char[] _tag, IReplacer[] _replacers)
        {
            string tag = new string(_tag, 2, _tag.Length - 3);

            foreach (IReplacer replacer in _replacers)
            {
                string result = replacer.Replace(tag);
                if (result != "")
                    return result;
            }
            return "";
        }
コード例 #11
0
 public ValueReplacementWriter(
     string input,
     IReplacer replacer,
     ContentWriterOptions options,
     TextWriter?textWriter           = null,
     MatchOutputInfo?outputInfo      = null,
     SpellcheckState?spellcheckState = null) : base(input, options, outputInfo: outputInfo)
 {
     Replacer        = replacer;
     _textWriter     = textWriter;
     SpellcheckState = spellcheckState;
 }
コード例 #12
0
        protected AskReplacementWriter(
            string input,
            IReplacer replacer,
            Lazy <TextWriter>?lazyWriter,
            ContentWriterOptions options,
            bool isInteractive,
            SpellcheckState?spellcheckState = null) : base(input, options)
        {
            Replacer        = replacer;
            IsInteractive   = isInteractive;
            SpellcheckState = spellcheckState;

            _lazyWriter = lazyWriter;
        }
コード例 #13
0
        public Typo(string dataDirectory)
        {
            _dataDirectory = dataDirectory;

            _keyboardListener          = new KeyboardListener();
            _keyboardListener.KeyDown += OnKeyboardKeyDown;
            _capsLockListener          = new CapsLockListener {
                IdleTimeout = TimeSpan.FromSeconds(10)
            };
            _capsLockListener.CapsLockStrokeEvent += OnCapsLockStrokeEvent;
            _inputter = new Inputter();

            _replacers = new List <IReplacer>();
            _inserters = new List <IInserter>();

            AddReplacer(new LuaReplacer());
            AddInserter(new LuaInserter());

            _typografReplacer = new TypografReplacer();
            _typografReplacer.Initialize(_dataDirectory);

            _scriptReplacer = new ScriptReplacer();
            _scriptReplacer.Initialize(_dataDirectory);
        }
コード例 #14
0
ファイル: ArrayOperation.cs プロジェクト: rvhuang/ostraka
 public ArrayOperation(IReplacer replacer, int arrayLength)
     : base(replacer)
 {
     this.buffer = new string[arrayLength];
 }
コード例 #15
0
ファイル: Operation.cs プロジェクト: rvhuang/ostraka
 protected Operation(IReplacer replacer)
 {
     this.replacer = replacer;
 }
コード例 #16
0
 public OptionGenerator(string filePathForLogger)
 {
     _replacer = new Replacer();
     _logger   = new Logger(filePathForLogger);
 }
コード例 #17
0
 public ReplacerTests()
 {
     kernel.Load(new DIRegistration());
     replacer = kernel.Get <IReplacer>();
 }