mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(dir): ♻ lint FilterListValueObject
This commit is contained in:
parent
9d8af88ebc
commit
90d77be847
3 changed files with 67 additions and 46 deletions
|
|
@ -2,30 +2,30 @@
|
|||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Changes;
|
||||
|
||||
public class FilterListChange : Change, IChangeAggregate<FilterListRecord>
|
||||
public class FilterListChange : Change, IChangeAggregate<FilterListValueObject>
|
||||
{
|
||||
protected FilterListChange() { }
|
||||
|
||||
public FilterListRecord? Before { get; private init; }
|
||||
public FilterListRecord? After { get; private init; }
|
||||
public FilterListValueObject? Before { get; private init; }
|
||||
public FilterListValueObject? After { get; private init; }
|
||||
|
||||
public static FilterListChange Create(FilterList filterList, string? reason)
|
||||
{
|
||||
return new FilterListChange { After = FilterListRecord.FromFilterList(filterList), Reason = reason };
|
||||
return new FilterListChange { After = FilterListValueObject.FromFilterList(filterList), Reason = reason };
|
||||
}
|
||||
|
||||
public static FilterListChange Update(FilterList before, FilterList after, string? reason)
|
||||
{
|
||||
return new FilterListChange
|
||||
{
|
||||
Before = FilterListRecord.FromFilterList(before),
|
||||
After = FilterListRecord.FromFilterList(after),
|
||||
Before = FilterListValueObject.FromFilterList(before),
|
||||
After = FilterListValueObject.FromFilterList(after),
|
||||
Reason = reason
|
||||
};
|
||||
}
|
||||
|
||||
public static FilterListChange Delete(FilterList filterList, string? reason)
|
||||
{
|
||||
return new FilterListChange { Before = FilterListRecord.FromFilterList(filterList), Reason = reason };
|
||||
return new FilterListChange { Before = FilterListValueObject.FromFilterList(filterList), Reason = reason };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.Licenses;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
|
||||
public record FilterListRecord(
|
||||
string Name,
|
||||
string? Description,
|
||||
License License,
|
||||
IEnumerable<FilterListViewUrl> ViewUrls,
|
||||
Uri? HomeUrl,
|
||||
Uri? OnionUrl,
|
||||
Uri? PolicyUrl,
|
||||
Uri? SubmissionUrl,
|
||||
Uri? IssuesUrl,
|
||||
Uri? ForumUrl,
|
||||
Uri? ChatUrl,
|
||||
string? EmailAddress,
|
||||
Uri? DonateUrl
|
||||
)
|
||||
{
|
||||
public static FilterListRecord FromFilterList(FilterList filterList)
|
||||
{
|
||||
return new FilterListRecord(
|
||||
filterList.Name,
|
||||
filterList.Description,
|
||||
filterList.License,
|
||||
filterList.ViewUrls,
|
||||
filterList.HomeUrl,
|
||||
filterList.OnionUrl,
|
||||
filterList.PolicyUrl,
|
||||
filterList.SubmissionUrl,
|
||||
filterList.IssuesUrl,
|
||||
filterList.ForumUrl,
|
||||
filterList.ChatUrl,
|
||||
filterList.EmailAddress,
|
||||
filterList.DonateUrl
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
|
||||
public class FilterListValueObject : ValueObject
|
||||
{
|
||||
public string Name { get; private init; } = default!;
|
||||
public string? Description { get; private init; }
|
||||
public long LicenseId { get; private init; }
|
||||
public IEnumerable<long> ViewUrlIds { get; private init; } = new HashSet<long>();
|
||||
public Uri? HomeUrl { get; private init; }
|
||||
public Uri? OnionUrl { get; private init; }
|
||||
public Uri? PolicyUrl { get; private init; }
|
||||
public Uri? SubmissionUrl { get; private init; }
|
||||
public Uri? IssuesUrl { get; private init; }
|
||||
public Uri? ForumUrl { get; private init; }
|
||||
public Uri? ChatUrl { get; private init; }
|
||||
public string? EmailAddress { get; private init; }
|
||||
public Uri? DonateUrl { get; private init; }
|
||||
|
||||
public static FilterListValueObject FromFilterList(FilterList filterList)
|
||||
{
|
||||
return new FilterListValueObject
|
||||
{
|
||||
Name = filterList.Name,
|
||||
Description = filterList.Description,
|
||||
LicenseId = filterList.License.Id,
|
||||
ViewUrlIds = filterList.ViewUrls.Select(u => u.Id),
|
||||
HomeUrl = filterList.HomeUrl,
|
||||
OnionUrl = filterList.OnionUrl,
|
||||
PolicyUrl = filterList.PolicyUrl,
|
||||
SubmissionUrl = filterList.SubmissionUrl,
|
||||
IssuesUrl = filterList.IssuesUrl,
|
||||
ForumUrl = filterList.ForumUrl,
|
||||
ChatUrl = filterList.ChatUrl,
|
||||
EmailAddress = filterList.EmailAddress,
|
||||
DonateUrl = filterList.DonateUrl
|
||||
};
|
||||
}
|
||||
|
||||
protected override IEnumerable<object?> GetEqualityComponents()
|
||||
{
|
||||
yield return Name;
|
||||
yield return Description;
|
||||
yield return LicenseId;
|
||||
foreach (long viewUrlId in ViewUrlIds)
|
||||
{
|
||||
yield return viewUrlId;
|
||||
}
|
||||
yield return HomeUrl;
|
||||
yield return OnionUrl;
|
||||
yield return PolicyUrl;
|
||||
yield return SubmissionUrl;
|
||||
yield return IssuesUrl;
|
||||
yield return ForumUrl;
|
||||
yield return ChatUrl;
|
||||
yield return EmailAddress;
|
||||
yield return DonateUrl;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue