/// <summary> /// Initializes the validator with the options received from the constructor overloads. /// </summary> /// <param name="format">Output format of error messages.</param> /// <param name="type">The <see cref="IXPathNavigable"/> type to use for validation and return type.</param> private void InitValidator(OutputFormatting format, NavigableType type) { if (!Enum.IsDefined(typeof(OutputFormatting), format)) { throw new ArgumentException("Invalid type.", "type"); } switch (format) { case OutputFormatting.Boolean: _evaluationctx.Formatter = new BooleanFormatter(); break; case OutputFormatting.Log: case OutputFormatting.Default: _evaluationctx.Formatter = new LogFormatter(); break; case OutputFormatting.Simple: _evaluationctx.Formatter = new SimpleFormatter(); break; case OutputFormatting.XML: _evaluationctx.Formatter = new XmlFormatter(); break; } if (!Enum.IsDefined(typeof(NavigableType), type)) { throw new ArgumentException("Invalid type.", "type"); } // If type is Default, set it to XPathDocument. _navtype = (type != NavigableType.Default) ? type : NavigableType.XPathDocument; }
/// <summary> /// Initializes a new instance of the class, using the specified options. /// </summary> /// <param name="format">Output format of error messages.</param> /// <param name="type">The <see cref="IXPathNavigable"/> type to use for validation and return type.</param> public Validator(OutputFormatting format, NavigableType type) : this() { InitValidator(format, type); }
/// <summary> /// Initializes a new instance of the class, using the specified return type. /// </summary> /// <param name="type">The <see cref="IXPathNavigable"/> type to use for validation and return type.</param> public Validator(NavigableType type) : this() { InitValidator(OutputFormatting.Default, type); }