public OUTTYPE IsLess <TValue>(PARAMNAME parameterName, TValue value, TValue max) where TValue : IComparable <TValue> { if (value.CompareTo(max) >= 0) { _SchemaThrow(parameterName, $"{value} must be less than {max}."); } return(this); }
public OUTTYPE AreEqual <TValue>(PARAMNAME parameterName, TValue value, TValue expected) where TValue : IEquatable <TValue> { if (!value.Equals(expected)) { _SchemaThrow(parameterName, $"{value} must be equal to {expected}."); } return(this); }
public OUTTYPE IsInRange <T>(PARAMNAME pname, T value, T minInclusive, T maxInclusive) where T : IComparable <T> { if (value.CompareTo(minInclusive) == -1) { _DataThrow(pname, $"is below minimum {minInclusive} value: {value}"); } if (value.CompareTo(maxInclusive) == +1) { _DataThrow(pname, $"is above maximum {maxInclusive} value: {value}"); } return(this); }
public OUTTYPE IsDefaultOrWithin <TValue>(PARAMNAME parameterName, TValue?value, TValue minInclusive, TValue maxInclusive) where TValue : unmanaged, IComparable <TValue> { if (!value.HasValue) { return(this); } if (value.Value.CompareTo(minInclusive) < 0) { _SchemaThrow(parameterName, $"{value} must be greater or equal to {minInclusive}."); } if (value.Value.CompareTo(maxInclusive) > 0) { _SchemaThrow(parameterName, $"{value} must be less or equal to {maxInclusive}."); } return(this); }
public OUTTYPE IsPosition(PARAMNAME pname, in System.Numerics.Vector3 position)
private void _DataThrow(PARAMNAME pname, string msg) { throw new DataException(_Current, $"{pname}: {msg}"); }
public OUTTYPE IsNullOrIndex <T>(PARAMNAME parameterName, int?index, IReadOnlyList <T> array) { return(IsNullOrInRange(parameterName, index, 1, array)); }
internal void _LinkThrow(PARAMNAME pname, string msg) { throw new LinkException(_Current, $"{pname.ToString()}: {msg}"); }
internal void _SchemaThrow(PARAMNAME pname, string msg) { throw new SchemaException(_Current, $"{pname}: {msg}"); }
public OUTTYPE IsValidURI(PARAMNAME parameterName, string gltfURI, params string[] validHeaders) { try { Guard.IsValidURI(parameterName, gltfURI, validHeaders); return(this); } catch (ArgumentException ex) { _SchemaThrow(parameterName, ex.Message); } return(this); }