private static string _CreateBaseMessage(TARGET target, String message) { if (target == null) { return(message); } var targetTypeInfo = target.GetType().GetTypeInfo(); var logicalIndexProp = targetTypeInfo.GetProperty("LogicalIndex"); var logicalIndex = logicalIndexProp != null ? (int)logicalIndexProp.GetValue(target) : -1; if (logicalIndex >= 0) { return($"{targetTypeInfo.Name}[{logicalIndex}] {message}"); } return($"{targetTypeInfo.Name} {message}"); }
public ValidationContext GetContext(TARGET target) { return(new ValidationContext(this, target)); }
internal ValidationContext(ValidationContext context, TARGET target) { _Root = context._Root; _Mode = context._Mode; _Current = target; }
internal LinkException(TARGET target, String message) : base(target, message) { }
internal SemanticException(TARGET target, String message) : base(target, message) { }
internal SchemaException(TARGET target, Newtonsoft.Json.JsonReaderException rex) : base(target, rex) { }
internal SchemaException(TARGET target, String message) : base(target, message) { }
public void AddError(TARGET target, String message) { _Exceptions.Add(new ModelException(target, message)); }
internal ModelException(TARGET target, Exception ex) : base(_CreateBaseMessage(target, ex.Message), ex) { _Target = target; }
internal ModelException(TARGET target, String message) : base(_CreateBaseMessage(target, message)) { _Target = target; }
public void UnsupportedExtensionError(TARGET target, String message) { AddLinkError(target, message); }
public void AddLinkError(TARGET target, String message) { _Exceptions.Add(new LinkException(target, message)); }
public void AddDataError(TARGET target, String message) { _Exceptions.Add(new DataException(target, message)); }
public void AddSemanticError(TARGET target, String message) { _Exceptions.Add(new SemanticException(target, message)); }
public void InvalidJson(TARGET target, string message) { AddSchemaError(target, $"Invalid JSON data. Parser output: {message}"); }
public ValidationContext(ValidationResult result, TARGET target) { _Result = result; _Target = target; }
public ValidationContext GetContext(TARGET target) { return(_Result.GetContext(target)); }
internal SchemaException(TARGET target, System.Text.Json.JsonException rex) : base(target, rex) { }