Skip to content

Commit

Permalink
replace value object types with record types
Browse files Browse the repository at this point in the history
  • Loading branch information
phongnguyend committed May 9, 2023
1 parent 032d794 commit a94bfc5
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 240 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Collections.Generic;
namespace ClassifiedAds.Domain.ValueObjects;

namespace ClassifiedAds.Domain.ValueObjects;

public class Address : ValueObject
public record Address
{
public string Street { get; private set; }

public string City { get; private set; }

public string ZipCode { get; private set; }

private Address()
Expand All @@ -18,11 +18,4 @@ public Address(string street, string city, string zipCode)
City = city;
ZipCode = zipCode;
}

protected override IEnumerable<object> GetEqualityComponents()
{
yield return Street;
yield return City;
yield return ZipCode;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Generic;
namespace ClassifiedAds.Domain.ValueObjects;

namespace ClassifiedAds.Domain.ValueObjects;

public class Money : ValueObject
public record Money
{
public decimal Amount { get; }

Expand All @@ -17,10 +15,4 @@ public Money(decimal amount, string currency)
Amount = amount;
Currency = currency;
}

protected override IEnumerable<object> GetEqualityComponents()
{
yield return Amount;
yield return Currency;
}
}

This file was deleted.

15 changes: 4 additions & 11 deletions src/ModularMonolith/ClassifiedAds.Domain/ValueObjects/Address.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Collections.Generic;
namespace ClassifiedAds.Domain.ValueObjects;

namespace ClassifiedAds.Domain.ValueObjects;

public class Address : ValueObject
public record Address
{
public string Street { get; private set; }

public string City { get; private set; }

public string ZipCode { get; private set; }

private Address()
Expand All @@ -18,11 +18,4 @@ public Address(string street, string city, string zipCode)
City = city;
ZipCode = zipCode;
}

protected override IEnumerable<object> GetEqualityComponents()
{
yield return Street;
yield return City;
yield return ZipCode;
}
}
12 changes: 2 additions & 10 deletions src/ModularMonolith/ClassifiedAds.Domain/ValueObjects/Money.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Generic;
namespace ClassifiedAds.Domain.ValueObjects;

namespace ClassifiedAds.Domain.ValueObjects;

public class Money : ValueObject
public record Money
{
public decimal Amount { get; }

Expand All @@ -17,10 +15,4 @@ public Money(decimal amount, string currency)
Amount = amount;
Currency = currency;
}

protected override IEnumerable<object> GetEqualityComponents()
{
yield return Amount;
yield return Currency;
}
}

This file was deleted.

15 changes: 4 additions & 11 deletions src/Monolith/ClassifiedAds.Domain/ValueObjects/Address.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Collections.Generic;
namespace ClassifiedAds.Domain.ValueObjects;

namespace ClassifiedAds.Domain.ValueObjects;

public class Address : ValueObject
public record Address
{
public string Street { get; private set; }

public string City { get; private set; }

public string ZipCode { get; private set; }

private Address()
Expand All @@ -18,11 +18,4 @@ public Address(string street, string city, string zipCode)
City = city;
ZipCode = zipCode;
}

protected override IEnumerable<object> GetEqualityComponents()
{
yield return Street;
yield return City;
yield return ZipCode;
}
}
12 changes: 2 additions & 10 deletions src/Monolith/ClassifiedAds.Domain/ValueObjects/Money.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Generic;
namespace ClassifiedAds.Domain.ValueObjects;

namespace ClassifiedAds.Domain.ValueObjects;

public class Money : ValueObject
public record Money
{
public decimal Amount { get; }

Expand All @@ -17,10 +15,4 @@ public Money(decimal amount, string currency)
Amount = amount;
Currency = currency;
}

protected override IEnumerable<object> GetEqualityComponents()
{
yield return Amount;
yield return Currency;
}
}
59 changes: 0 additions & 59 deletions src/Monolith/ClassifiedAds.Domain/ValueObjects/ValueObject.cs

This file was deleted.

0 comments on commit a94bfc5

Please sign in to comment.