Skip to content

Commit

Permalink
Reformatting.
Browse files Browse the repository at this point in the history
Updating version.
  • Loading branch information
ardalis committed Feb 9, 2021
1 parent f7d6091 commit 303ac01
Show file tree
Hide file tree
Showing 20 changed files with 328 additions and 328 deletions.
16 changes: 8 additions & 8 deletions SharedKernel/src/PluralsightDdd.SharedKernel/BaseDomainEvent.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using MediatR;
using System;
using System;
using MediatR;

namespace PluralsightDdd.SharedKernel
{
public abstract class BaseDomainEvent : INotification
{
public DateTime DateOccurred { get; protected set; } = DateTime.UtcNow;
}
}
{
public abstract class BaseDomainEvent : INotification
{
public DateTime DateOccurred { get; protected set; } = DateTime.UtcNow;
}
}
16 changes: 8 additions & 8 deletions SharedKernel/src/PluralsightDdd.SharedKernel/BaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace PluralsightDdd.SharedKernel
{
/// <summary>
/// Base types for all Entities which track state using a given Id.
/// </summary>
public abstract class BaseEntity<TId>
{
public TId Id { get; set; }
/// <summary>
/// Base types for all Entities which track state using a given Id.
/// </summary>
public abstract class BaseEntity<TId>
{
public TId Id { get; set; }

public List<BaseDomainEvent> Events = new List<BaseDomainEvent>();
}
public List<BaseDomainEvent> Events = new List<BaseDomainEvent>();
}
}
100 changes: 50 additions & 50 deletions SharedKernel/src/PluralsightDdd.SharedKernel/DateTimeRange.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
using Ardalis.GuardClauses;
using System;
using System;
using System.Collections.Generic;
using Ardalis.GuardClauses;

namespace PluralsightDdd.SharedKernel
{
public class DateTimeRange : ValueObject
{
public DateTime Start { get; private set; }
public DateTime End { get; private set; }
public class DateTimeRange : ValueObject
{
public DateTime Start { get; private set; }
public DateTime End { get; private set; }

public DateTimeRange(DateTime start, DateTime end)
{
// Ardalis.GuardClauses supports extensions with custom guards per project
Guard.Against.OutOfRange(start, nameof(start), start, end);
Start = start;
End = end;
}
public DateTimeRange(DateTime start, DateTime end)
{
// Ardalis.GuardClauses supports extensions with custom guards per project
Guard.Against.OutOfRange(start, nameof(start), start, end);
Start = start;
End = end;
}

public DateTimeRange(DateTime start, TimeSpan duration) : this(start, start.Add(duration))
{
}
public DateTimeRange(DateTime start, TimeSpan duration) : this(start, start.Add(duration))
{
}

public int DurationInMinutes()
{
return (int)Math.Round((End - Start).TotalMinutes, 0);
}
public int DurationInMinutes()
{
return (int)Math.Round((End - Start).TotalMinutes, 0);
}

public DateTimeRange NewDuration(TimeSpan newDuration)
{
return new DateTimeRange(this.Start, newDuration);
}
public DateTimeRange NewDuration(TimeSpan newDuration)
{
return new DateTimeRange(this.Start, newDuration);
}

public DateTimeRange NewEnd(DateTime newEnd)
{
return new DateTimeRange(this.Start, newEnd);
}
public DateTimeRange NewEnd(DateTime newEnd)
{
return new DateTimeRange(this.Start, newEnd);
}

public DateTimeRange NewStart(DateTime newStart)
{
return new DateTimeRange(newStart, this.End);
}
public DateTimeRange NewStart(DateTime newStart)
{
return new DateTimeRange(newStart, this.End);
}

public static DateTimeRange CreateOneDayRange(DateTime day)
{
return new DateTimeRange(day, day.AddDays(1));
}
public static DateTimeRange CreateOneDayRange(DateTime day)
{
return new DateTimeRange(day, day.AddDays(1));
}

public static DateTimeRange CreateOneWeekRange(DateTime startDay)
{
return new DateTimeRange(startDay, startDay.AddDays(7));
}
public static DateTimeRange CreateOneWeekRange(DateTime startDay)
{
return new DateTimeRange(startDay, startDay.AddDays(7));
}

public bool Overlaps(DateTimeRange dateTimeRange)
{
return this.Start < dateTimeRange.End &&
this.End > dateTimeRange.Start;
}
public bool Overlaps(DateTimeRange dateTimeRange)
{
return this.Start < dateTimeRange.End &&
this.End > dateTimeRange.Start;
}

protected override IEnumerable<object> GetEqualityComponents()
{
yield return Start;
yield return End;
}
protected override IEnumerable<object> GetEqualityComponents()
{
yield return Start;
yield return End;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace PluralsightDdd.SharedKernel.Interfaces
{
// Apply this marker interface only to aggregate root entities
// Repositories will only work with aggregate roots, not their children
public interface IAggregateRoot { }
}
// Apply this marker interface only to aggregate root entities
// Repositories will only work with aggregate roots, not their children
public interface IAggregateRoot { }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace PluralsightDdd.SharedKernel.Interfaces
{
public interface IApplicationEvent
{
string EventType { get; }
}
public interface IApplicationEvent
{
string EventType { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace PluralsightDdd.SharedKernel.Interfaces
{
public interface IDomainEvent
{
/// <summary>
/// UTC DateTime when event occurred
/// </summary>
DateTime DateTimeEventOccurred { get; }
}
public interface IDomainEvent
{
/// <summary>
/// UTC DateTime when event occurred
/// </summary>
DateTime DateTimeEventOccurred { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace PluralsightDdd.SharedKernel.Interfaces
{
public interface IHandle<T> where T : BaseDomainEvent
{
Task HandleAsync(T args);
}
public interface IHandle<T> where T : BaseDomainEvent
{
Task HandleAsync(T args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<Summary>Includes common abstractions and base types.</Summary>
<RepositoryUrl>https://github.com/ardalis/pluralsight-ddd-fundamentals</RepositoryUrl>
<PackageTags>aspnet asp.net aspnetcore asp.net core ddd dddesign value object entity aggregate domain event</PackageTags>
<PackageReleaseNotes>Adding XML doc comments.</PackageReleaseNotes>
<Version>1.0.1</Version>
<PackageReleaseNotes>Adding Get with Specification to Repository.</PackageReleaseNotes>
<Version>1.0.2</Version>
<AssemblyName>PluralsightDdd.SharedKernel</AssemblyName>
<PackageIconUrl>https://user-images.githubusercontent.com/782127/33497760-facf6550-d69c-11e7-94e4-b3856da259a9.png</PackageIconUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand Down
Loading

0 comments on commit 303ac01

Please sign in to comment.