More equality shenanigans
This commit is contained in:
parent
ec4ed6f0be
commit
6a10e8c631
|
@ -4,8 +4,8 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|||
|
||||
namespace Authinator.Backend.Database.Tables;
|
||||
|
||||
public record ACL {
|
||||
public int Id { get; set; }
|
||||
public class ACL {
|
||||
public int Id { get; }
|
||||
public string Name { get; set; } = null!;
|
||||
public bool Enabled { get; set; } = true;
|
||||
public string Target { get; set; } = null!;
|
||||
|
@ -27,4 +27,20 @@ public record ACL {
|
|||
acl.HasMany(p => p.Users).WithMany();
|
||||
}
|
||||
}
|
||||
|
||||
private bool Equals(ACL other) => Id == other.Id;
|
||||
|
||||
public override bool Equals(object? obj) {
|
||||
if (ReferenceEquals(null, obj))
|
||||
return false;
|
||||
if (ReferenceEquals(this, obj))
|
||||
return true;
|
||||
return obj.GetType() == GetType() && Equals((ACL)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Id;
|
||||
|
||||
public static bool operator ==(ACL? left, ACL? right) => Equals(left, right);
|
||||
|
||||
public static bool operator !=(ACL? left, ACL? right) => !Equals(left, right);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|||
|
||||
namespace Authinator.Backend.Database.Tables;
|
||||
|
||||
public record Group {
|
||||
public int Id { get; set; }
|
||||
public class Group {
|
||||
public int Id { get; }
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public class Configuration : IEntityTypeConfiguration<Group> {
|
||||
|
@ -14,4 +14,20 @@ public record Group {
|
|||
group.Property(b => b.Name).HasColumnName("Name").IsRequired();
|
||||
}
|
||||
}
|
||||
|
||||
private bool Equals(Group other) => Id == other.Id;
|
||||
|
||||
public override bool Equals(object? obj) {
|
||||
if (ReferenceEquals(null, obj))
|
||||
return false;
|
||||
if (ReferenceEquals(this, obj))
|
||||
return true;
|
||||
return obj.GetType() == GetType() && Equals((Group)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Id;
|
||||
|
||||
public static bool operator ==(Group? left, Group? right) => Equals(left, right);
|
||||
|
||||
public static bool operator !=(Group? left, Group? right) => !Equals(left, right);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|||
|
||||
namespace Authinator.Backend.Database.Tables;
|
||||
|
||||
public record Network {
|
||||
public int Id { get; set; }
|
||||
public class Network {
|
||||
public int Id { get; }
|
||||
public string Name { get; set; } = null!;
|
||||
public IPAddress Subnet { get; set; } = null!;
|
||||
|
||||
|
@ -17,4 +17,20 @@ public record Network {
|
|||
group.Property(b => b.Name).HasColumnName("Subnet").IsRequired();
|
||||
}
|
||||
}
|
||||
|
||||
private bool Equals(Network other) => Id == other.Id;
|
||||
|
||||
public override bool Equals(object? obj) {
|
||||
if (ReferenceEquals(null, obj))
|
||||
return false;
|
||||
if (ReferenceEquals(this, obj))
|
||||
return true;
|
||||
return obj.GetType() == GetType() && Equals((Network)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Id;
|
||||
|
||||
public static bool operator ==(Network? left, Network? right) => Equals(left, right);
|
||||
|
||||
public static bool operator !=(Network? left, Network? right) => !Equals(left, right);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|||
namespace Authinator.Backend.Database.Tables;
|
||||
|
||||
public class User {
|
||||
public int Id { get; set; }
|
||||
public int Id { get; }
|
||||
public int Iteration { get; set; }
|
||||
public string Reference { get; set; } = null!;
|
||||
public string? Username { get; set; }
|
||||
|
|
Loading…
Reference in a new issue