Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Dec 21, 2023
2 parents 0a2910d + 970fcdb commit 21d5ab8
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BUTR.Site.NexusMods.Server.Models;
namespace BUTR.Site.NexusMods.Server.Models;

public static class OpenApiExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public static readonly TType User = From(ApplicationRoles.User);
public static readonly TType Moderator = From(ApplicationRoles.Moderator);
public static readonly TType Administrator = From(ApplicationRoles.Administrator);

public static TType DefaultValue => Anonymous;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public readonly partial struct CrashReportId : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment>
{
public static TType DefaultValue => From(Guid.Empty);

public static TType NewRandomValue(Random? random) => From(Guid.NewGuid());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public readonly partial struct CrashReportUrl : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment>
{
public static TType DefaultValue => From(string.Empty);

public static TType From(Uri uri) => From(uri.ToString());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BUTR.Site.NexusMods.Server.Models;
namespace BUTR.Site.NexusMods.Server.Models;

internal interface IValueObjectFrom<TValueType, TInnerValue>
where TValueType : IValueObjectFrom<TValueType, TInnerValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public readonly partial struct NexusModsApiKey : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment>, IValueObjectFrom<TType, TValueType>
{
public static readonly TType None = From(string.Empty);

public static TType DefaultValue => None;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static bool TryParse(string articleIdRaw, out TType articleId)
articleId = result ? From(articleIdVal) : DefaultValue;
return result;
}

public static bool TryParseUrl(string? urlRaw, out TType articleId)
{
articleId = From(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public static readonly TType Bannerlord = From(TenantUtils.BannerlordGameDomain);
public static readonly TType Rimworld = From(TenantUtils.RimworldGameDomain);
public static readonly TType StardewValley = From(TenantUtils.StardewValleyGameDomain);

public static TType DefaultValue => None;

public static IEnumerable<TType> Values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static bool TryParse(string modIdRaw, out TType modId)
modId = result ? From(modIdVal) : DefaultValue;
return result;
}

public static bool TryParseUrl(string? urlRaw, out TType modId)
{
modId = DefaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public readonly partial struct NexusModsUserEMail : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment>
{
public static readonly TType Empty = From(string.Empty);

public static TType DefaultValue => Empty;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public readonly partial struct NexusModsUserId : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment>
{
public static readonly TType None = From(0);

public static TType DefaultValue => None;

public static bool TryParse(string userIdRaw, out TType userId)
Expand All @@ -16,7 +16,7 @@ public static bool TryParse(string userIdRaw, out TType userId)
userId = result ? From(userIdVal) : DefaultValue;
return result;
}

public static bool TryParseUrl(string? urlRaw, out TType userId)
{
userId = DefaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public readonly partial struct NexusModsUserName : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment>
{
public static readonly TType Empty = From(string.Empty);

public static TType DefaultValue => Empty;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace BUTR.Site.NexusMods.Server.Models;
public static readonly TType Bannerlord = From(TenantUtils.BannerlordId);
public static readonly TType Rimworld = From(TenantUtils.RimworldId);
public static readonly TType StardewValley = From(TenantUtils.StardewValleyId);

public static TType DefaultValue => None;

public static IEnumerable<TType> Values
Expand Down
20 changes: 12 additions & 8 deletions src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
global using BUTR.Site.NexusMods.Shared.Helpers;
global using BUTR.Site.NexusMods.Server.Models;
global using BUTR.Site.NexusMods.Server.ValueObjects.Utils;
global using BUTR.Site.NexusMods.Server.Utils;
global using Microsoft.Extensions.DependencyInjection;
global using BUTR.Site.NexusMods.Server.ValueObjects.Utils;
global using BUTR.Site.NexusMods.Shared.Helpers;

global using Microsoft.EntityFrameworkCore;
global using Microsoft.EntityFrameworkCore.ChangeTracking;
global using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
global using Microsoft.EntityFrameworkCore.Metadata.Builders;
global using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.OpenApi.Models;

global using Swashbuckle.AspNetCore.SwaggerGen;

global using System.ComponentModel;
global using System.Diagnostics.CodeAnalysis;
global using System.Globalization;
global using System.Reflection;
global using System.Runtime.CompilerServices;
global using System.Runtime.InteropServices;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using System.ComponentModel;
global using System.Globalization;
global using System.Reflection;
global using Swashbuckle.AspNetCore.SwaggerGen;

global using TransparentValueObjects;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BUTR.Site.NexusMods.Server.ValueObjects.Utils;
namespace BUTR.Site.NexusMods.Server.ValueObjects.Utils;

internal class TransparentValueObjectTypeConverter<TValueType, TInnerValue> : TypeConverter
where TValueType : struct, IValueObjectFrom<TValueType, TInnerValue>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BUTR.Site.NexusMods.Server.Utils;
namespace BUTR.Site.NexusMods.Server.Utils;

public static class QueryableHelper
{
Expand Down

0 comments on commit 21d5ab8

Please sign in to comment.