Skip to content

Commit

Permalink
Merge pull request #40 from henrikfroehling/GH-35
Browse files Browse the repository at this point in the history
Resolves GH-35
  • Loading branch information
henrikfroehling committed Jul 28, 2018
2 parents b70e57f + 87e10c3 commit 9c5bb5a
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 106 deletions.
41 changes: 41 additions & 0 deletions Source/Lib/Trakt.NET/Objects/Post/PostEpisode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace TraktNet.Objects.Post
{
using Basic;
using System;

/// <summary>Contains an episode number, optional metadata about the episode and an optional datetime.</summary>
public sealed class PostEpisode
{
/// <summary>Initializes a new instance of the <see cref="PostEpisode" /> class.</summary>
public PostEpisode() : this(-1) { }

/// <summary>Initializes a new instance of the <see cref="PostEpisode" /> class.</summary>
/// <param name="number">The number of this episode.</param>
public PostEpisode(int number) : this(number, null) { }

/// <summary>Initializes a new instance of the <see cref="PostEpisode" /> class.</summary>
/// <param name="number">The number of this episode.</param>
/// <param name="metadata">Metadata about the episode.</param>
public PostEpisode(int number, ITraktMetadata metadata) : this(number, metadata, null) { }

/// <summary>Initializes a new instance of the <see cref="PostEpisode" /> class.</summary>
/// <param name="number">The number of this episode.</param>
/// <param name="metadata">Metadata about the episode.</param>
/// <param name="at">An UTC datetime.</param>
public PostEpisode(int number, ITraktMetadata metadata, DateTime? at)
{
Number = number;
Metadata = metadata;
At = at;
}

/// <summary>Gets or sets the number of this episode.</summary>
public int Number { get; set; }

/// <summary>Gets or sets the metadata of this episode.</summary>
public ITraktMetadata Metadata { get; set; }

/// <summary>Gets or sets a UTC datetime of this episode.</summary>
public DateTime? At { get; set; }
}
}
18 changes: 13 additions & 5 deletions Source/Lib/Trakt.NET/Objects/Post/PostEpisodes.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
namespace TraktNet.Objects.Post
{
using Basic;
using System;
using System.Collections;
using System.Collections.Generic;

/// <summary>A list of episode numbers.</summary>
public sealed class PostEpisodes : IEnumerable<int>
public sealed class PostEpisodes : IEnumerable<PostEpisode>
{
private readonly List<int> _episodes;
private readonly List<PostEpisode> _episodes;

/// <summary>Initializes a new instance of the <see cref="PostEpisodes" /> class.</summary>
public PostEpisodes()
{
_episodes = new List<int>();
_episodes = new List<PostEpisode>();
}

/// <summary>Adds the given episode number to the list.</summary>
/// <param name="episode">The episode number, which will be added to the list.</param>
/// <param name="metadata">Metadata about the given episode.</param>
/// <param name="at">An UTC datetime.</param>
public void Add(int episode, ITraktMetadata metadata = null, DateTime? at = null) => _episodes.Add(new PostEpisode(episode, metadata, at));

/// <summary>Adds the given episode numbers to the list.</summary>
/// <param name="episode">An episode number, which will be added to the list.</param>
/// <param name="episodes">An optional array of episode numbers, which will be added to the list.</param>
public void Add(int episode, params int[] episodes)
public void Add(PostEpisode episode, params PostEpisode[] episodes)
{
_episodes.Add(episode);

if (episodes?.Length > 0)
_episodes.AddRange(episodes);
}

public IEnumerator<int> GetEnumerator() => _episodes.GetEnumerator();
public IEnumerator<PostEpisode> GetEnumerator() => _episodes.GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
Expand Down
Loading

0 comments on commit 9c5bb5a

Please sign in to comment.