コード例 #1
0
        public void EmptyNode_TryGetAttribute_ReturnsFalse(Fb2Node instance)
        {
            if (instance.AllowedAttributes.Count == 0)
            {
                return;
            }

            instance.Attributes.Should().BeEmpty();

            instance.TryGetAttribute(instance.AllowedAttributes.First(), out var result)
            .Should()
            .BeFalse();

            //result.Key.Should().BeNullOrEmpty();
            //result.Value.Should().BeNullOrEmpty();
            result.Should().BeNull();
            //result.Value.Should().BeNullOrEmpty();

            instance.TryGetAttribute(instance.AllowedAttributes.First(), true, out var resultIgnoreCase)
            .Should()
            .BeFalse();

            resultIgnoreCase.Should().BeNull();

            //resultIgnoreCase.Key.Should().BeNullOrEmpty();
            //resultIgnoreCase.Value.Should().BeNullOrEmpty();
        }
コード例 #2
0
        private static string GetCellAlignment(Fb2Node cell, string alignAttributeName)
        {
            if (cell == null || string.IsNullOrWhiteSpace(alignAttributeName))
            {
                throw new ArgumentNullException();
            }

            if (cell.TryGetAttribute(alignAttributeName, true, out var align))
            {
                return(align !.Value);
            }

            return(string.Empty);
        }
コード例 #3
0
        // if no span found return 1 as minimal cell unit width/height
        private static int GetCellSpan(Fb2Node cell, string spanAttrName)
        {
            if (cell == null || string.IsNullOrWhiteSpace(spanAttrName))
            {
                throw new ArgumentNullException();
            }

            if (cell.TryGetAttribute(spanAttrName, true, out var span) &&
                int.TryParse(span !.Value, out int spanNumber) && spanNumber > 1)
            {
                return(spanNumber);
            }

            return(1);
        }