3using HotChocolate.Language;
4using HotChocolate.Types;
20 Description =
"Represents a version in semantic versioning format";
21 SpecifiedBy =
new Uri(
"https://semver.org/spec/v2.0.0.html");
29 public override bool TryDeserialize(
object? resultValue, out
object? runtimeValue)
31 if (resultValue is not
string resultString)
37 var result = Version.TryParse(resultString, out var resultVersion);
38 runtimeValue = resultVersion;
43 public override bool TrySerialize(
object? runtimeValue, out
object? resultValue)
45 if (runtimeValue is not Version runtimeVersion)
51 resultValue = runtimeVersion.Semver().ToString();
56 protected override Version
ParseLiteral(StringValueNode valueSyntax)
58 ArgumentNullException.ThrowIfNull(valueSyntax);
59 return Version.Parse(valueSyntax.Value);
63 protected override StringValueNode
ParseValue(Version runtimeValue)
64 =>
new(runtimeValue.Semver().ToString());
69 ArgumentNullException.ThrowIfNull(valueSyntax);
70 return Version.TryParse(valueSyntax.Value, out var parsedVersion)
77 ArgumentNullException.ThrowIfNull(runtimeValue);
78 return runtimeValue.Build != -1 && runtimeValue.Revision == -1;
A ScalarType<TRuntimeType, TLiteral> for semantic Versions.
override bool TryDeserialize(object? resultValue, out object? runtimeValue)
override IValueNode ParseResult(object? resultValue)
override bool IsInstanceOfType(StringValueNode valueSyntax)
override Version ParseLiteral(StringValueNode valueSyntax)
SemverType()
Initializes a new instance of the SemverType class.
override bool IsInstanceOfType(Version runtimeValue)
override StringValueNode ParseValue(Version runtimeValue)
override bool TrySerialize(object? runtimeValue, out object? resultValue)