コード例 #1
0
        protected override void InitialValidation(
            ICanvas <ConsolePixelData> canvas,
            IConsoleInputContext inputContext)
        {
            ValidateCanvas(canvas);
            ValidateNumberOfInputParts(inputContext, 4, "Fill Area");

            if (inputContext.InputParts[3].Length != 1)
            {
                throw new ValidationException("Colour must be a single character.");
            }
        }
コード例 #2
0
        protected override ICanvas <ConsolePixelData> ExecuteInternal(
            ICanvas <ConsolePixelData> canvas,
            IConsoleInputContext inputContext)
        {
            // Currently only default supported.
            var defaultForegroundPixel = _canvasConfiguration.DefaultForegroundPixel;

            CoreCommand.Draw(
                canvas,
                ParsePoint(inputContext, 1, 2),
                ParsePoint(inputContext, 3, 4),
                defaultForegroundPixel);

            return(canvas);
        }
コード例 #3
0
        protected override ICanvas <ConsolePixelData> ExecuteInternal(
            ICanvas <ConsolePixelData> canvas,
            IConsoleInputContext inputContext)
        {
            var dimensions = ParsePoint(inputContext, 1, 2);

            if (_canvasConfiguration.MaxHeight.HasValue && dimensions.Y > _canvasConfiguration.MaxHeight)
            {
                throw new ValidationException($"Maximum height is {_canvasConfiguration.MaxHeight}.");
            }

            if (_canvasConfiguration.MaxWidth.HasValue && dimensions.X > _canvasConfiguration.MaxWidth)
            {
                throw new ValidationException($"Maximum width is {_canvasConfiguration.MaxWidth}.");
            }

            return(CoreCommand.Create(dimensions.X, dimensions.Y));
        }
コード例 #4
0
        protected static ConsolePixel ParseColour(IConsoleInputContext inputContext, int partIndex)
        {
            if (inputContext?.InputParts == null)
            {
                throw new ArgumentException("inputContext or InputParts null.");
            }

            var inputPartLength = inputContext.InputParts?.Length;

            if (inputPartLength < partIndex)
            {
                throw new InvalidOperationException($"inputPartLength: {inputPartLength}, partIndex: {partIndex}");
            }

            return(new ConsolePixel(new ConsolePixelData
            {
                Colour = inputContext.InputParts[partIndex][0]
            }));
        }
コード例 #5
0
 protected override void InitialValidation(
     ICanvas <ConsolePixelData> canvas,
     IConsoleInputContext inputContext)
 {
     ValidateNumberOfInputParts(inputContext, 3, "Create Canvas");
 }
コード例 #6
0
 protected override void InitialValidation(ICanvas <ConsolePixelData> canvas, IConsoleInputContext inputContext)
 {
     ValidateCanvas(canvas);
     ValidateNumberOfInputParts(inputContext, 5, "Fill Line");
 }