public void RaiseError(ValidationError error) { // shared cache information that could be read/populated from multiple threads // lock to ensure that only one thread writes known schemas if (!_knownSchemasPopulated) { lock (Schema.KnownSchemas) { if (!_knownSchemasPopulated) { if (Schema.KnownSchemas.Count == 0) { JSchemaDiscovery discovery = new JSchemaDiscovery(Schema, Schema.KnownSchemas, KnownSchemaState.External); discovery.Discover(Schema, null); } _knownSchemasPopulated = true; } } } PopulateSchemaId(error); SchemaValidationEventHandler handler = ValidationEventHandler; if (handler != null) { handler(_publicValidator, new SchemaValidationEventArgs(error)); } else { throw JSchemaValidationException.Create(error); } }
public void RaiseError(IFormattable message, ErrorType errorType, JSchema schema, object value, IList <ValidationError> childErrors) { ValidationError error = CreateError(message, errorType, schema, value, childErrors); // shared cache information that could be read/populated from multiple threads // lock to ensure that only one thread writes known schemas if (Schema.KnownSchemas.Count == 0) { lock (Schema.KnownSchemas) { if (Schema.KnownSchemas.Count == 0) { JSchemaDiscovery discovery = new JSchemaDiscovery(Schema.KnownSchemas, KnownSchemaState.External); discovery.Discover(Schema, null); } } } PopulateSchemaId(error); SchemaValidationEventHandler handler = ValidationEventHandler; if (handler != null) { handler(_publicValidator, new SchemaValidationEventArgs(error)); } else { throw JSchemaValidationException.Create(error); } }
private void RaiseSchemaValidationError(object sender, SchemaValidationEventArgs e) { throw JSchemaReaderException.Create( (JsonReader)sender, _baseUri, "Validation error raised by version schema '{0}': {1}".FormatWith(CultureInfo.InvariantCulture, _schemaVersionUri, e.ValidationError.Message), JSchemaValidationException.Create(e.ValidationError)); }
public void RaiseError(string message, ErrorType errorType, JSchema schema, object value, IList <ValidationError> childErrors) { ValidationError error = CreateError(message, errorType, schema, value, childErrors); SchemaValidationEventHandler handler = ValidationEventHandler; if (handler != null) { handler(_publicValidator, new SchemaValidationEventArgs(error)); } else { throw JSchemaValidationException.Create(error); } }