﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HashTag.Versioning
{
    public partial class NetVersion
    {


        protected void ValidateQualifiers(List<Qualifier> qualifiers)
        {
            if (qualifiers.Count != 1 )
            {
                throw new ArgumentException("There MUST be only one (2-4) part dot segmented qualifier");
            }
        }
        protected void ValidateSegmentsForQualifier(int currentIndex, List<Qualifier> Qualifiers)
        {
            var qualifier = Qualifiers[0];
            if (qualifier.Segments.Count < 2 || qualifier.Segments.Count > 4)
            {
                throw new ArgumentException("There MUST be between 2-4 dotted separated segments");
            }

            base.ValidateSegmentsForQualifier(currentIndex, Qualifiers);
            foreach (var segment in qualifier.Segments)
            {
                if (string.IsNullOrWhiteSpace(segment.SegmentText))
                {
                    throw new ArgumentException("Each segment must be non-negative integer GTE 0 and LT 65534");
                }
                if (segment.IsNumeric == false)
                {
                    throw new ArgumentException("Each segment must be non-negative integer GTE 0 and LT 65534");
                }
                if (segment.NumericValue > 65534)
                {
                    throw new ArgumentException("Each segment must be non-negative integer GTE 0 and LT 65534");
                }
            }
        }

    }
}
