public object ReadYaml(IParser parser, Type type)
        {
            var scalar = (YamlDotNet.Core.Events.Scalar)parser.Current;
            var value  = scalar.Value;

            if (string.IsNullOrWhiteSpace(value))
            {
                parser.MoveNext();
                return(null);
            }

            var values = value
                         .Split(delimiter, StringSplitOptions.RemoveEmptyEntries)
                         .ToList();

            Color?color = TryParseEachAndRemove <Color?>(values,
                                                         x => {
                bool success = ColorX.TryParse(x, out Color c);
                return(success, c);
            });
            int?size = TryParseEachAndRemove(values, x
                                             => {
                bool success = int.TryParse(x, out int number);
                return(success, number);
            });

            var result = new BorderSideStyle
            {
                Width = size ?? 0,
                Color = color ?? Color.Transparent,
            };

            parser.MoveNext();
            return(result);
        }
Example #2
0
        public BorderStyle(BorderStyle parent = null)
        {
            _parent = parent;

            Left   = new BorderSideStyle(_parent?.Left);
            Top    = new BorderSideStyle(_parent?.Top);
            Right  = new BorderSideStyle(_parent?.Right);
            Bottom = new BorderSideStyle(_parent?.Bottom);
        }
Example #3
0
 public BorderStyle(BorderSideStyle top, BorderSideStyle rightAndLeft, BorderSideStyle bottom)
     : this($"{top} {rightAndLeft} {bottom}")
 {
 }
Example #4
0
 public BorderStyle(BorderSideStyle topAndBottom, BorderSideStyle rightAndLeft)
     : this($"{topAndBottom} {rightAndLeft}")
 {
 }
Example #5
0
 public BorderStyle(BorderSideStyle top, BorderSideStyle right, BorderSideStyle bottom, BorderSideStyle left)
     : this($"{top} {right} {bottom} {left}")
 {
 }
Example #6
0
 public Border(BorderSideStyle style)
     : base($"{style}")
 {
 }
Example #7
0
 public Border(BorderSideWidth width, BorderSideStyle style, CssColor borderColor)
     : this($"{width} {style} {borderColor}")
 {
 }
Example #8
0
 public Border(BorderSideWidth width, BorderSideStyle style)
     : this($"{width} {style}")
 {
 }
Example #9
0
 public Border(BorderSideStyle style, CssColor borderColor)
     : this($"{style} {borderColor}")
 {
 }