public static ICacheable GetFromCache(this IJsonCacheable json, TrelloAuthorization auth) { if (json == null) { return(null); } return(TrelloConfiguration.Cache.Find <ICacheable>(o => o.Id == json.Id) ?? JsonFactory[JsonTypeMap[json.GetType()]](json, auth, null)); }
public static ICacheable GetFromCache(this IJsonCacheable json, TrelloAuthorization auth) { if (json == null) { return(null); } Type jsonType = json.GetType(); if (!jsonType.IsInterface) { jsonType = JsonTypeMap.Keys.Intersect(jsonType.GetInterfaces()).FirstOrDefault(); if (jsonType == null) { throw new InvalidOperationException($"Type `{json.GetType().Name}` implements more than one Manatee.Trello.Json interface. " + $"Please provide separate classes for each interface."); } } return(TrelloConfiguration.Cache.Find <ICacheable>(json.Id) ?? JsonFactory[JsonTypeMap[jsonType]](json, auth, null)); }