mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 03:11:10 +00:00
Adds media consumption rules and centralizes authorization role names
This commit is contained in:
1 parent
3e32068573
commit
8a5cb9116e
56 files changed
+767
-80
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a kind of media whose sessions count when they are completed or reach a minimum consumed duration. I.e.: movies.
|
||||
/// </summary>
|
||||
public abstract class DurationThresholdConsumptionRule : MediaConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the minimum consumed duration that a session of this kind of media must reach to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public abstract TimeSpan MinimumCountedDuration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a consumption session of this kind of media counts towards statistics.
|
||||
/// </summary>
|
||||
/// <param name="status">The status of the consumption session.</param>
|
||||
/// <param name="consumedDuration">The active duration consumed by the consumption session.</param>
|
||||
/// <param name="consecutivePagesRead">The number of consecutive pages read in the consumption session. It is ignored, because this kind of media is counted by duration.</param>
|
||||
/// <returns><see langword="true"/> if the consumption session counts towards statistics, <see langword="false"/> otherwise.</returns>
|
||||
public override bool Counts(ConsumptionStatus status, TimeSpan consumedDuration, int consecutivePagesRead)
|
||||
{
|
||||
return status == ConsumptionStatus.Completed || consumedDuration >= MinimumCountedDuration;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a kind of media whose sessions count every time, regardless of their duration or progress. I.e.: photos.
|
||||
/// </summary>
|
||||
public abstract class EverySessionConsumptionRule : MediaConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether a consumption session of this kind of media counts towards statistics.
|
||||
/// </summary>
|
||||
/// <param name="status">The status of the consumption session. It is ignored, because every session of this kind of media counts.</param>
|
||||
/// <param name="consumedDuration">The active duration consumed by the consumption session. It is ignored, because every session of this kind of media counts.</param>
|
||||
/// <param name="consecutivePagesRead">The number of consecutive pages read in the consumption session. It is ignored, because every session of this kind of media counts.</param>
|
||||
/// <returns><see langword="true"/>, because every session of this kind of media counts towards statistics.</returns>
|
||||
public override bool Counts(ConsumptionStatus status, TimeSpan consumedDuration, int consecutivePagesRead)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a kind of media.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The rules are shared by the consumption record aggregate, the resume point aggregate and the statistics read model, so they live in the common
|
||||
/// folder of the bounded context. Each concrete rule describes the counting behavior and the resumability of one media kind, and the factory returns
|
||||
/// the rule for a kind so that callers never switch on the media kind themselves.
|
||||
/// </remarks>
|
||||
public abstract class MediaConsumptionRule : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public abstract MediaKind MediaKind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public abstract bool IsSupportedByCurrentCatalogues { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media, if the kind can be resumed.
|
||||
/// </summary>
|
||||
public abstract Optional<MediaPositionKind> PositionKind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether a consumption session of this kind of media can be resumed.
|
||||
/// </summary>
|
||||
public bool CanResume => PositionKind.HasValue;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a consumption session of this kind of media counts towards statistics.
|
||||
/// </summary>
|
||||
/// <param name="status">The status of the consumption session.</param>
|
||||
/// <param name="consumedDuration">The active duration consumed by the consumption session.</param>
|
||||
/// <param name="consecutivePagesRead">The number of consecutive pages read in the consumption session.</param>
|
||||
/// <returns><see langword="true"/> if the consumption session counts towards statistics, <see langword="false"/> otherwise.</returns>
|
||||
public abstract bool Counts(ConsumptionStatus status, TimeSpan consumedDuration, int consecutivePagesRead);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the consumption rule for <paramref name="mediaKind"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">The kind of media for which to get the consumption rule.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Optional{TValue}"/> containing the consumption rule for <paramref name="mediaKind"/>, or no value when the kind has no rule.
|
||||
/// </returns>
|
||||
public static Optional<MediaConsumptionRule> For(MediaKind mediaKind)
|
||||
{
|
||||
return mediaKind switch
|
||||
{
|
||||
MediaKind.MusicTrack => Optional<MediaConsumptionRule>.Some(new MusicTrackConsumptionRule()),
|
||||
MediaKind.PodcastEpisode => Optional<MediaConsumptionRule>.Some(new PodcastEpisodeConsumptionRule()),
|
||||
MediaKind.Audiobook => Optional<MediaConsumptionRule>.Some(new AudiobookConsumptionRule()),
|
||||
MediaKind.Movie => Optional<MediaConsumptionRule>.Some(new MovieConsumptionRule()),
|
||||
MediaKind.TvEpisode => Optional<MediaConsumptionRule>.Some(new TvEpisodeConsumptionRule()),
|
||||
MediaKind.Book => Optional<MediaConsumptionRule>.Some(new BookConsumptionRule()),
|
||||
MediaKind.Photo => Optional<MediaConsumptionRule>.Some(new PhotoConsumptionRule()),
|
||||
MediaKind.Video => Optional<MediaConsumptionRule>.Some(new VideoConsumptionRule()),
|
||||
_ => Optional<MediaConsumptionRule>.None()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object?> GetEqualityComponents()
|
||||
{
|
||||
yield return MediaKind;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a kind of media whose sessions count when they are completed or reach a minimum number of consecutive pages read. I.e.: books.
|
||||
/// </summary>
|
||||
public abstract class PageThresholdConsumptionRule : MediaConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the minimum number of consecutive pages that a session of this kind of media must read to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public abstract int MinimumConsecutivePages { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a consumption session of this kind of media counts towards statistics.
|
||||
/// </summary>
|
||||
/// <param name="status">The status of the consumption session.</param>
|
||||
/// <param name="consumedDuration">The active duration consumed by the consumption session. It is ignored, because this kind of media is counted by pages.</param>
|
||||
/// <param name="consecutivePagesRead">The number of consecutive pages read in the consumption session.</param>
|
||||
/// <returns><see langword="true"/> if the consumption session counts towards statistics, <see langword="false"/> otherwise.</returns>
|
||||
public override bool Counts(ConsumptionStatus status, TimeSpan consumedDuration, int consecutivePagesRead)
|
||||
{
|
||||
return status == ConsumptionStatus.Completed || consecutivePagesRead > MinimumConsecutivePages;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a media library, duplicated from the LibraryManagement bounded context to keep the cross bounded context references decoupled.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Value}")]
|
||||
public sealed class LibraryId : EntityId<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private LibraryId(Guid value) : base(value)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="LibraryId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="LibraryId"/> instance.</returns>
|
||||
public static LibraryId CreateUnique()
|
||||
{
|
||||
return new LibraryId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="LibraryId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="LibraryId"/> instance.</param>
|
||||
/// <returns>The created <see cref="LibraryId"/> instance.</returns>
|
||||
public static LibraryId Create(Guid value)
|
||||
{
|
||||
return new LibraryId(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a media item, duplicated from the media library bounded contexts to keep the cross bounded context references decoupled.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Value}")]
|
||||
public sealed class MediaItemId : EntityId<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaItemId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private MediaItemId(Guid value) : base(value)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaItemId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="MediaItemId"/> instance.</returns>
|
||||
public static MediaItemId CreateUnique()
|
||||
{
|
||||
return new MediaItemId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaItemId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="MediaItemId"/> instance.</param>
|
||||
/// <returns>The created <see cref="MediaItemId"/> instance.</returns>
|
||||
public static MediaItemId Create(Guid value)
|
||||
{
|
||||
return new MediaItemId(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a user, duplicated from the UserManagement bounded context to keep the cross bounded context references decoupled.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Value}")]
|
||||
public sealed class UserId : EntityId<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UserId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private UserId(Guid value) : base(value)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="UserId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="UserId"/> instance.</returns>
|
||||
public static UserId CreateUnique()
|
||||
{
|
||||
return new UserId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="UserId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="UserId"/> instance.</param>
|
||||
/// <returns>The created <see cref="UserId"/> instance.</returns>
|
||||
public static UserId Create(Guid value)
|
||||
{
|
||||
return new UserId(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of an audiobook.
|
||||
/// </summary>
|
||||
public sealed class AudiobookConsumptionRule : DurationThresholdConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public override MediaKind MediaKind { get; } = MediaKind.Audiobook;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public override bool IsSupportedByCurrentCatalogues { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media, if the kind can be resumed.
|
||||
/// </summary>
|
||||
public override Optional<MediaPositionKind> PositionKind { get; } = MediaPositionKind.TimeOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum consumed duration that a session of this kind of media must reach to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public override TimeSpan MinimumCountedDuration { get; } = TimeSpan.FromSeconds(60);
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a book.
|
||||
/// </summary>
|
||||
public sealed class BookConsumptionRule : PageThresholdConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public override MediaKind MediaKind { get; } = MediaKind.Book;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public override bool IsSupportedByCurrentCatalogues { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media, if the kind can be resumed.
|
||||
/// </summary>
|
||||
public override Optional<MediaPositionKind> PositionKind { get; } = MediaPositionKind.Location;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum number of consecutive pages that a session of this kind of media must read to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public override int MinimumConsecutivePages { get; } = 5;
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a movie.
|
||||
/// </summary>
|
||||
public sealed class MovieConsumptionRule : DurationThresholdConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public override MediaKind MediaKind { get; } = MediaKind.Movie;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public override bool IsSupportedByCurrentCatalogues { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media, if the kind can be resumed.
|
||||
/// </summary>
|
||||
public override Optional<MediaPositionKind> PositionKind { get; } = MediaPositionKind.TimeOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum consumed duration that a session of this kind of media must reach to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public override TimeSpan MinimumCountedDuration { get; } = TimeSpan.FromMinutes(3);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a music track.
|
||||
/// </summary>
|
||||
public sealed class MusicTrackConsumptionRule : DurationThresholdConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public override MediaKind MediaKind { get; } = MediaKind.MusicTrack;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public override bool IsSupportedByCurrentCatalogues { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media, if the kind can be resumed.
|
||||
/// </summary>
|
||||
public override Optional<MediaPositionKind> PositionKind { get; } = MediaPositionKind.TimeOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum consumed duration that a session of this kind of media must reach to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public override TimeSpan MinimumCountedDuration { get; } = TimeSpan.FromSeconds(30);
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a photo.
|
||||
/// </summary>
|
||||
public sealed class PhotoConsumptionRule : EverySessionConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public override MediaKind MediaKind { get; } = MediaKind.Photo;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public override bool IsSupportedByCurrentCatalogues { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media. A photo cannot be resumed, so it has no position kind.
|
||||
/// </summary>
|
||||
public override Optional<MediaPositionKind> PositionKind { get; } = Optional<MediaPositionKind>.None();
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a podcast episode.
|
||||
/// </summary>
|
||||
public sealed class PodcastEpisodeConsumptionRule : DurationThresholdConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public override MediaKind MediaKind { get; } = MediaKind.PodcastEpisode;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public override bool IsSupportedByCurrentCatalogues { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media, if the kind can be resumed.
|
||||
/// </summary>
|
||||
public override Optional<MediaPositionKind> PositionKind { get; } = MediaPositionKind.TimeOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum consumed duration that a session of this kind of media must reach to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public override TimeSpan MinimumCountedDuration { get; } = TimeSpan.FromSeconds(30);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a TV show episode.
|
||||
/// </summary>
|
||||
public sealed class TvEpisodeConsumptionRule : DurationThresholdConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public override MediaKind MediaKind { get; } = MediaKind.TvEpisode;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public override bool IsSupportedByCurrentCatalogues { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media, if the kind can be resumed.
|
||||
/// </summary>
|
||||
public override Optional<MediaPositionKind> PositionKind { get; } = MediaPositionKind.TimeOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum consumed duration that a session of this kind of media must reach to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public override TimeSpan MinimumCountedDuration { get; } = TimeSpan.FromMinutes(3);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the consumption rules of a video.
|
||||
/// </summary>
|
||||
public sealed class VideoConsumptionRule : DurationThresholdConsumptionRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of media that this rule applies to.
|
||||
/// </summary>
|
||||
public override MediaKind MediaKind { get; } = MediaKind.Video;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current catalogues support this kind of media.
|
||||
/// </summary>
|
||||
public override bool IsSupportedByCurrentCatalogues { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of position used to resume this kind of media, if the kind can be resumed.
|
||||
/// </summary>
|
||||
public override Optional<MediaPositionKind> PositionKind { get; } = MediaPositionKind.TimeOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum consumed duration that a session of this kind of media must reach to be counted, when it is not completed.
|
||||
/// </summary>
|
||||
public override TimeSpan MinimumCountedDuration { get; } = TimeSpan.FromMinutes(3);
|
||||
}
|
||||
Reference in new issue
Block a user