-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[modgen] Ajout hash des modules dans le lockfile
- Loading branch information
Showing
5 changed files
with
111 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using YamlDotNet.Core; | ||
using YamlDotNet.Core.Events; | ||
using YamlDotNet.Serialization; | ||
|
||
namespace TopModel.Utils; | ||
|
||
public class TopModelLockModule : TopModelLockModuleBase, IYamlConvertible | ||
{ | ||
/// <inheritdoc cref="IYamlConvertible.Read" /> | ||
public void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer) | ||
{ | ||
if (parser.TryConsume<Scalar>(out var version)) | ||
{ | ||
Version = version.Value; | ||
} | ||
else if (parser.Current is MappingStart) | ||
{ | ||
var lol = (TopModelLockModuleBase)nestedObjectDeserializer(typeof(TopModelLockModuleBase))!; | ||
Version = lol.Version; | ||
Hash = lol.Hash; | ||
} | ||
} | ||
|
||
/// <inheritdoc cref="IYamlConvertible.Write" /> | ||
public void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer) | ||
{ | ||
if (Hash != null) | ||
{ | ||
nestedObjectSerializer(new TopModelLockModuleBase { Version = Version, Hash = Hash }); | ||
} | ||
else | ||
{ | ||
emitter.Emit(new Scalar(Version)); | ||
} | ||
} | ||
} | ||
|
||
#pragma warning disable SA1402 | ||
public class TopModelLockModuleBase | ||
{ | ||
public required string Version { get; set; } | ||
|
||
public string? Hash { get; set; } | ||
} |