generated from Nexus-Mods/NexusMods.App.Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
72 additions
and
51 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/NexusMods.MnemonicDB.Abstractions/Attributes/AbsolutePathAttribute.cs
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,22 @@ | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NexusMods.MnemonicDB.Abstractions.ValueSerializers; | ||
using NexusMods.Paths; | ||
|
||
namespace NexusMods.MnemonicDB.Abstractions.Attributes; | ||
|
||
/// <summary> | ||
/// An attribute that holds an <see cref="AbsolutePath"/>. | ||
/// </summary> | ||
[PublicAPI] | ||
public sealed class AbsolutePathAttribute(string ns, string name) : ScalarAttribute<AbsolutePath, string, Utf8InsensitiveSerializer>(ns, name) | ||
{ | ||
/// <inheritdoc/> | ||
protected override string ToLowLevel(AbsolutePath value) => value.ToString(); | ||
|
||
/// <inheritdoc/> | ||
protected override AbsolutePath FromLowLevel(string value, AttributeResolver resolver) | ||
{ | ||
return resolver.ServiceProvider.GetRequiredService<IFileSystem>().FromUnsanitizedFullPath(value); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/NexusMods.MnemonicDB.Abstractions/Attributes/RelativePathAttribute.cs
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,22 @@ | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NexusMods.MnemonicDB.Abstractions.ValueSerializers; | ||
using NexusMods.Paths; | ||
|
||
namespace NexusMods.MnemonicDB.Abstractions.Attributes; | ||
|
||
/// <summary> | ||
/// An attribute that holds an <see cref="RelativePath"/>. | ||
/// </summary> | ||
[PublicAPI] | ||
public sealed class RelativePathAttribute(string ns, string name) : ScalarAttribute<RelativePath, string, Utf8InsensitiveSerializer>(ns, name) | ||
{ | ||
/// <inheritdoc/> | ||
protected override string ToLowLevel(RelativePath value) => value.ToString(); | ||
|
||
/// <inheritdoc/> | ||
protected override RelativePath FromLowLevel(string value, AttributeResolver resolver) | ||
{ | ||
return new RelativePath(value); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/NexusMods.MnemonicDB.Abstractions/Attributes/SizeAttribute.cs
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,18 @@ | ||
using JetBrains.Annotations; | ||
using NexusMods.MnemonicDB.Abstractions.ValueSerializers; | ||
using NexusMods.Paths; | ||
|
||
namespace NexusMods.MnemonicDB.Abstractions.Attributes; | ||
|
||
/// <summary> | ||
/// An attribute that holds an <see cref="Size"/>. | ||
/// </summary> | ||
[PublicAPI] | ||
public sealed class SizeAttribute(string ns, string name) : ScalarAttribute<Size, ulong, UInt64Serializer>(ns, name) | ||
{ | ||
/// <inheritdoc/> | ||
protected override ulong ToLowLevel(Size value) => value.Value; | ||
|
||
/// <inheritdoc/> | ||
protected override Size FromLowLevel(ulong value, AttributeResolver resolver) => Size.From(value); | ||
} |
12 changes: 8 additions & 4 deletions
12
....TestModel/Attributes/StringsAttribute.cs → ...stractions/Attributes/StringsAttribute.cs
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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
using NexusMods.MnemonicDB.Abstractions; | ||
using NexusMods.MnemonicDB.Abstractions.Attributes; | ||
using NexusMods.MnemonicDB.Abstractions.ElementComparers; | ||
using JetBrains.Annotations; | ||
using NexusMods.MnemonicDB.Abstractions.ValueSerializers; | ||
|
||
namespace NexusMods.MnemonicDB.TestModel.Attributes; | ||
namespace NexusMods.MnemonicDB.Abstractions.Attributes; | ||
|
||
/// <summary> | ||
/// An attribute that holds a collection of strings. | ||
/// </summary> | ||
[PublicAPI] | ||
public sealed class StringsAttribute(string ns, string name) : CollectionAttribute<string, string, Utf8Serializer>(ns, name) | ||
{ | ||
/// <inheritdoc/> | ||
protected override string ToLowLevel(string value) => value; | ||
|
||
/// <inheritdoc/> | ||
protected override string FromLowLevel(string value, AttributeResolver resolver) => value; | ||
} |
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
17 changes: 0 additions & 17 deletions
17
tests/NexusMods.MnemonicDB.TestModel/Attributes/AbsolutePathAttribute.cs
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
tests/NexusMods.MnemonicDB.TestModel/Attributes/RelativePathAttribute.cs
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
tests/NexusMods.MnemonicDB.TestModel/Attributes/SizeAttribute.cs
This file was deleted.
Oops, something went wrong.