-
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tidusjar
committed
Apr 6, 2016
1 parent
08cbf92
commit 3efd54c
Showing
7 changed files
with
57 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
namespace PlexRequests.Api.Models.SickRage | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using PlexRequests.Helpers; | ||
|
||
namespace PlexRequests.Api.Models.SickRage | ||
{ | ||
public class SickRageSeasonList : SickRageBase<int[]> | ||
public class SickRageSeasonList : SickRageBase<object> | ||
{ | ||
[JsonIgnore] | ||
public int[] Data => ParseObjectToArray<int>(data); | ||
|
||
protected T[] ParseObjectToArray<T>(object ambiguousObject) | ||
{ | ||
var json = ambiguousObject.ToString(); | ||
if (string.IsNullOrWhiteSpace(json)) | ||
{ | ||
return new T[0]; // Could return null here instead. | ||
} | ||
if (json.TrimStart().StartsWith("[")) | ||
{ | ||
return JsonConvert.DeserializeObject<T[]>(json); | ||
} | ||
if (json.TrimStart().Equals("{}")) | ||
{ | ||
return new T[0]; | ||
} | ||
|
||
return new T[1] { JsonConvert.DeserializeObject<T>(json) }; | ||
|
||
} | ||
} | ||
} |
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