Esempio n. 1
0
        private static ValidationResult Validate(ViolationCollector collector, IDocumentSchema schema, IAutomatonDocument document, IDocOp docOp)
        {
            if (schema == null)
            {
                schema = DocumentSchema.NoSchemaConstraints;
            }

            var automation = new DocOpAutomaton(document, schema);
            var accu = new ValidationResult[] { ValidationResult.Valid };
            try
            {
                docOp.Apply(new ValidationDocOpCursor(collector, automation, accu));
            }
            catch (IllFormedException illFormed)
            {
                return ValidationResult.IllFormed;
            }

            accu[0] = accu[0].MergeWith(automation.CheckFinish(collector));
            return accu[0];
        }
Esempio n. 2
0
 internal static string ToConciseString(IDocOp docOp)
 {
     var sb = new StringBuilder();
     docOp.Apply(CreateConciseStringBuilder(docOp, sb));
     return sb.ToString();
 }
Esempio n. 3
0
        /// <summary>
        /// Computes the number of items of the document that an op applies to, prior to its application.
        /// </summary>
        public static int InitialDocumentLength(IDocOp docOp)
        {
            int[] size = { 0 };

            docOp.Apply(new InitialDocumentLengthDocOpCursor(size));

            return size[0];
        }
Esempio n. 4
0
        public static IDocOp Normalize(IDocOp input)
        {
            var normalizer = new AnnotationsNormalizer<IDocOp>(new RangeNormalizer<IDocOp>(new DocOpBuffer()));
            input.Apply(normalizer);

            return normalizer.Finish();
        }
Esempio n. 5
0
        /// <summary>
        /// Computes the number of items of the document that an op produces when applied.
        /// </summary>
        public static int ResultingDocumentLength(IDocOp docOp)
        {
            int[] size = { 0 };

            docOp.Apply(new ResultingDocumentLengthDocOpCursor(size));

            return size[0];
        }