예제 #1
0
        protected override void OnValidate(PatternCheckContext context)
        {
            if (Value is OptionalElement)
            {
                throw new Exception("Nested optional elements don't add anything");
            }

            Value.Validate(context);
        }
예제 #2
0
        protected override void OnValidate(PatternCheckContext context)
        {
            if (Elements.Count == 0)
            {
                throw new Exception("Option has no elements!");
            }

            foreach (PatternElement element in Elements)
            {
                element.Validate(context);

                if (element is OptionalElement)
                {
                    throw new Exception("Optional Option element");
                }
            }
        }
예제 #3
0
파일: Sequence.cs 프로젝트: Seti-0/NSprak
        protected override void OnValidate(PatternCheckContext context)
        {
            if (Elements.Count == 0)
            {
                throw new Exception("Sequence has no elements");
            }

            context.BeginSequenceScope();

            foreach (PatternElement element in Elements)
            {
                element.Validate(context);
            }

            if (Elements.Last() is OptionalElement option &&
                option.Value is EndElement)
            {
                throw new Exception("A final optional end will never execute");
            }

            context.EndSequenceScope();
        }
예제 #4
0
 protected override void OnValidate(PatternCheckContext context)
 {
     // Nothing to check here.
 }