-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Resolves GH-30
- Loading branch information
Showing
40 changed files
with
859 additions
and
180 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Source/Lib/Trakt.NET/Objects/Basic/Json/Writer/AMetadataObjectJsonWriter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace TraktNet.Objects.Basic.Json.Writer | ||
{ | ||
using Enums; | ||
using Newtonsoft.Json; | ||
using Objects.Json; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
internal abstract class AMetadataObjectJsonWriter<TMetadataObjectType> : AObjectJsonWriter<TMetadataObjectType> where TMetadataObjectType : ITraktMetadata | ||
{ | ||
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, TMetadataObjectType obj, CancellationToken cancellationToken = default) | ||
{ | ||
if (jsonWriter == null) | ||
throw new ArgumentNullException(nameof(jsonWriter)); | ||
|
||
await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); | ||
await WriteMetadataObjectAsync(jsonWriter, obj, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
protected virtual async Task WriteMetadataObjectAsync(JsonTextWriter jsonWriter, TMetadataObjectType obj, CancellationToken cancellationToken = default) | ||
{ | ||
if (obj.MediaType != null && obj.MediaType != TraktMediaType.Unspecified) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_MEDIA_TYPE, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.MediaType.ObjectName, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (obj.MediaResolution != null && obj.MediaResolution != TraktMediaResolution.Unspecified) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_RESOLUTION, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.MediaResolution.ObjectName, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (obj.Audio != null && obj.Audio != TraktMediaAudio.Unspecified) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_AUDIO, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.Audio.ObjectName, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (obj.AudioChannels != null && obj.AudioChannels != TraktMediaAudioChannel.Unspecified) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_AUDIO_CHANNELS, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.AudioChannels.ObjectName, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (obj.ThreeDimensional.HasValue) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_3D, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.ThreeDimensional, cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} |
48 changes: 1 addition & 47 deletions
48
Source/Lib/Trakt.NET/Objects/Basic/Json/Writer/MetadataObjectJsonWriter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,6 @@ | ||
namespace TraktNet.Objects.Basic.Json.Writer | ||
{ | ||
using Enums; | ||
using Newtonsoft.Json; | ||
using Objects.Json; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
internal class MetadataObjectJsonWriter : AObjectJsonWriter<ITraktMetadata> | ||
internal class MetadataObjectJsonWriter : AMetadataObjectJsonWriter<ITraktMetadata> | ||
{ | ||
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktMetadata obj, CancellationToken cancellationToken = default) | ||
{ | ||
if (jsonWriter == null) | ||
throw new ArgumentNullException(nameof(jsonWriter)); | ||
|
||
await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); | ||
|
||
if (obj.MediaType != null && obj.MediaType != TraktMediaType.Unspecified) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_MEDIA_TYPE, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.MediaType.ObjectName, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (obj.MediaResolution != null && obj.MediaResolution != TraktMediaResolution.Unspecified) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_RESOLUTION, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.MediaResolution.ObjectName, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (obj.Audio != null && obj.Audio != TraktMediaAudio.Unspecified) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_AUDIO, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.Audio.ObjectName, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (obj.AudioChannels != null && obj.AudioChannels != TraktMediaAudioChannel.Unspecified) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_AUDIO_CHANNELS, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.AudioChannels.ObjectName, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (obj.ThreeDimensional.HasValue) | ||
{ | ||
await jsonWriter.WritePropertyNameAsync(JsonProperties.METADATA_PROPERTY_NAME_3D, cancellationToken).ConfigureAwait(false); | ||
await jsonWriter.WriteValueAsync(obj.ThreeDimensional, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
Source/Lib/Trakt.NET/Objects/Post/Syncs/Collection/ITraktSyncCollectionPostShowEpisode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
namespace TraktNet.Objects.Post.Syncs.Collection | ||
{ | ||
public interface ITraktSyncCollectionPostShowEpisode | ||
using Basic; | ||
using System; | ||
|
||
public interface ITraktSyncCollectionPostShowEpisode : ITraktMetadata | ||
{ | ||
int Number { get; set; } | ||
|
||
DateTime? CollectedAt { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
...t.NET/Objects/Post/Syncs/Collection/Implementations/TraktSyncCollectionPostShowEpisode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
namespace TraktNet.Objects.Post.Syncs.Collection | ||
{ | ||
using Basic; | ||
using System; | ||
|
||
/// <summary>A Trakt collection post episode, containing the required episode number.</summary> | ||
public class TraktSyncCollectionPostShowEpisode : ITraktSyncCollectionPostShowEpisode | ||
public class TraktSyncCollectionPostShowEpisode : TraktMetadata, ITraktSyncCollectionPostShowEpisode | ||
{ | ||
/// <summary>Gets or sets the required season number of the Trakt episode.</summary> | ||
public int Number { get; set; } | ||
|
||
public DateTime? CollectedAt { get; set; } | ||
} | ||
} |
8 changes: 3 additions & 5 deletions
8
...ET/Objects/Post/Syncs/Collection/Json/Factories/SyncCollectionPostEpisodeJsonIOFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
...Trakt.NET/Objects/Post/Syncs/Collection/Json/Factories/SyncCollectionPostJsonIOFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
....NET/Objects/Post/Syncs/Collection/Json/Factories/SyncCollectionPostMovieJsonIOFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.