Ejemplo n.º 1
0
        public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx)
        {
            if (cki.Key != ConsoleKey.DownArrow)
            {
                return;
            }
            var inputBuffer  = ctx.Get <InputBuffer>();
            var inputHistory = ctx.Get <InputHistory>();

            var current = inputBuffer.GetInput();

            if (current.Length != 0)
            {
                inputHistory.Update(current);
            }

            current = inputHistory.Next();
            if (current == null)
            {
                return;
            }

            inputBuffer.ForceSetInput(current);
            inputBuffer.ForceSetCursorPos(current.Length);
        }
Ejemplo n.º 2
0
        public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx)
        {
            if (cki.Key != ConsoleKey.Enter)
            {
                return;
            }

            var current = ctx.Get <InputBuffer>().GetInput();

            if (current.Length == 0)
            {
                return;
            }

            var inputHistory = ctx.Get <InputHistory>();

            inputHistory.Last();
            if (inputHistory.Pre() == current)
            {
                inputHistory.Next();
                return;
            }

            inputHistory.Next();
            inputHistory.Update(current);
            inputHistory.Enqueue(string.Empty);
        }
Ejemplo n.º 3
0
 public override void OnRegist(ContextContainer ctx)
 {
     if (ctx.Get <InputHistory>() == null)
     {
         ctx.Set(new InputHistory(100));
     }
 }
Ejemplo n.º 4
0
        public void MustContainContextAfterInclude()
        {
            var c1 = new Mock <FakeContext>();

            _sut.Include(c1.Object);
            var c1ByType      = _sut.Get <FakeContext>();
            var c1ByNamespace = _sut.Get <FakeContext>(typeof(FakeContext).FullName);

            Assert.Equal(c1.Object, c1ByType);
            Assert.Equal(c1.Object, c1ByNamespace);
        }
Ejemplo n.º 5
0
 public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx)
 {
     ctx.Get <InputBuffer>().CursorLeftMove();
 }
Ejemplo n.º 6
0
 public void MustThrowExceptionWhenFullQualifiedNamespaceOfTypeDoesntExist()
 => FluentActions.Invoking(() => _sut.Get <int>("not.a.real.namespace")).Should().Throw <KeyNotFoundException>();
Ejemplo n.º 7
0
 public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx)
 {
     ctx.Get <InputBuffer>()?.Delete();
 }
Ejemplo n.º 8
0
 public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx)
 {
     ctx.Get <InputBuffer>()?.Insert(cki.KeyChar);
 }