Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Commit

Permalink
GH-78: Add correct types in JsonFactoryContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikfroehling committed Sep 30, 2017
1 parent 2dd76f9 commit 71927e5
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace TraktApiSharp.Objects.JsonReader
{
using Authentication;
using Authentication.Implementations;
using Authentication.JsonReader.Factories;
using Basic;
using Basic.JsonReader.Factories;
Expand Down Expand Up @@ -68,23 +68,23 @@ internal static class JsonFactoryContainer
{
private static readonly Dictionary<Type, object> s_readerFactories = new Dictionary<Type, object>();

public static IObjectJsonReader<TReturnType> CreateObjectReader<TReturnType>()
internal static IObjectJsonReader<TReturnType> CreateObjectReader<TReturnType>()
{
var factory = GetReaderFactory<TReturnType>();
IJsonReaderFactory<TReturnType> factory = GetReaderFactory<TReturnType>();
Debug.Assert(factory != null, $"factory for {nameof(TReturnType)} should not be null");
return factory.CreateObjectReader();
}

public static IArrayJsonReader<TReturnType> CreateArrayReader<TReturnType>()
internal static IArrayJsonReader<TReturnType> CreateArrayReader<TReturnType>()
{
var factory = GetReaderFactory<TReturnType>();
IJsonReaderFactory<TReturnType> factory = GetReaderFactory<TReturnType>();
Debug.Assert(factory != null, $"factory for {nameof(TReturnType)} should not be null");
return factory.CreateArrayReader();
}

public static IJsonReaderFactory<TReturnType> GetReaderFactory<TReturnType>()
internal static IJsonReaderFactory<TReturnType> GetReaderFactory<TReturnType>()
{
var type = typeof(TReturnType);
Type type = typeof(TReturnType);

if (!s_readerFactories.ContainsKey(type))
throw new NotSupportedException($"A json reader factory for {nameof(TReturnType)} is not supported.");
Expand All @@ -95,8 +95,8 @@ public static IJsonReaderFactory<TReturnType> GetReaderFactory<TReturnType>()
static JsonFactoryContainer()
{
// authentication objects
s_readerFactories.Add(typeof(ITraktAuthorization), new AuthorizationJsonReaderFactory());
s_readerFactories.Add(typeof(ITraktDevice), new DeviceJsonReaderFactory());
s_readerFactories.Add(typeof(TraktAuthorization), new AuthorizationJsonReaderFactory());
s_readerFactories.Add(typeof(TraktDevice), new DeviceJsonReaderFactory());

// basic objects
s_readerFactories.Add(typeof(ITraktCastAndCrew), new CastAndCrewJsonReaderFactory());
Expand Down

0 comments on commit 71927e5

Please sign in to comment.