Esempio n. 1
0
        /// <summary>
        /// Creates a <see cref="MultipartBlockParser{T}"/>.
        /// </summary>
        /// <param name="multipartBlockFactory">The factory for creating <typeparamref name="T"/>s.</param>
        /// <param name="name"><typeparamref name="T"/>'s name. Expected in its opening line.</param>
        /// <param name="partTypes">The <see cref="PartType"/> of each part of a <typeparamref name="T"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="multipartBlockFactory"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown if <paramref name="name"/> is <c>null</c>, whitespace or an empty string.</exception>
        /// <exception cref="ArgumentException">Thrown if <paramref name="partTypes"/> is <c>null</c> or empty.</exception>
        protected MultipartBlockParser(IMultipartBlockFactory <T> multipartBlockFactory,
                                       string name,
                                       PartType[] partTypes)
        {
            _multipartBlockFactory = multipartBlockFactory ?? throw new ArgumentNullException(nameof(multipartBlockFactory));

            if (!(partTypes?.Length > 0))
            {
                throw new ArgumentException(nameof(partTypes));
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(nameof(name));
            }

            OpeningCharacters = new char[] { '+' };
            _name             = name;
            _nameLength       = _name.Length;
            _partTypes        = partTypes;
            _numParts         = _partTypes.Length;
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a <see cref="FlexiCardBlockParser"/>.
 /// </summary>
 /// <param name="flexiCardBlockFactory">The factory for building <see cref="FlexiCardBlock"/>s.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="flexiCardBlockFactory"/> is <c>null</c>.</exception>
 public FlexiCardBlockParser(IMultipartBlockFactory <FlexiCardBlock> flexiCardBlockFactory) :
     base(flexiCardBlockFactory, "card", new PartType[] { PartType.Leaf, PartType.Container, PartType.Leaf })
 {
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a <see cref="FlexiTabBlockParser"/>.
 /// </summary>
 /// <param name="flexiTabBlockFactory">The factory for building <see cref="FlexiTabBlock"/>s.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="flexiTabBlockFactory"/> is <c>null</c>.</exception>
 public FlexiTabBlockParser(IMultipartBlockFactory <FlexiTabBlock> flexiTabBlockFactory) :
     base(flexiTabBlockFactory, "tab", new PartType[] { PartType.Leaf, PartType.Container })
 {
 }
Esempio n. 4
0
 /// <summary>
 /// Creates a <see cref="FlexiQuoteBlockParser"/>.
 /// </summary>
 /// <param name="flexiQuoteBlockFactory">The factory for building <see cref="FlexiQuoteBlock"/>s.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="flexiQuoteBlockFactory"/> is <c>null</c>.</exception>
 public FlexiQuoteBlockParser(IMultipartBlockFactory <FlexiQuoteBlock> flexiQuoteBlockFactory) :
     base(flexiQuoteBlockFactory, "quote", new PartType[] { PartType.Container, PartType.Leaf })
 {
 }
Esempio n. 5
0
 public ExposedMultipartBlockParser(IMultipartBlockFactory <DummyMultipartBlock> multipartBlockFactory, string name, PartType[] partTypes) :
     base(multipartBlockFactory, name, partTypes)
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Creates a <see cref="FlexiBannerBlockParser"/>.
 /// </summary>
 /// <param name="flexiBannerBlockFactory">The factory for building <see cref="FlexiBannerBlock"/>s.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="flexiBannerBlockFactory"/> is <c>null</c>.</exception>
 public FlexiBannerBlockParser(IMultipartBlockFactory <FlexiBannerBlock> flexiBannerBlockFactory) :
     base(flexiBannerBlockFactory, "banner", new PartType[] { PartType.Leaf, PartType.Leaf })
 {
 }