|
|
@ -1,4 +1,7 @@ |
|
|
|
using System; |
|
|
|
using IPA.Config.Data; |
|
|
|
using IPA.Config.Stores; |
|
|
|
using IPA.Config.Stores.Converters; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Version = SemVer.Version; |
|
|
|
|
|
|
@ -241,4 +244,27 @@ namespace IPA.Utilities |
|
|
|
/// <seealso cref="SemverValue"/>
|
|
|
|
public static implicit operator Version(AlmostVersion av) => av?.SemverValue; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A <see cref="ValueConverter{T}"/> for <see cref="AlmostVersion"/>s.
|
|
|
|
/// </summary>
|
|
|
|
public sealed class AlmostVersionConverter : ValueConverter<AlmostVersion> |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="Text"/> node into an <see cref="AlmostVersion"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">the <see cref="Text"/> node to convert</param>
|
|
|
|
/// <param name="parent">the owner of the new object</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public override AlmostVersion FromValue(Value value, object parent) |
|
|
|
=> new AlmostVersion(Converter<string>.Default.FromValue(value, parent)); |
|
|
|
/// <summary>
|
|
|
|
/// Converts an <see cref="AlmostVersion"/> to a <see cref="Text"/> node.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="obj">the <see cref="AlmostVersion"/> to convert</param>
|
|
|
|
/// <param name="parent">the parent of <paramref name="obj"/></param>
|
|
|
|
/// <returns>a <see cref="Text"/> node representing <paramref name="obj"/></returns>
|
|
|
|
public override Value ToValue(AlmostVersion obj, object parent) |
|
|
|
=> Value.From(obj.ToString()); |
|
|
|
} |
|
|
|
} |