本文整理汇总了C#中Series.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# Series.Deserialize方法的具体用法?C# Series.Deserialize怎么用?C# Series.Deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Series
的用法示例。
在下文中一共展示了Series.Deserialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSeriesByRemoteId
/// <summary>
/// Gets the series by either its imdb or zap2it id.
/// </summary>
/// <param name="imdbId">IMDB id</param>
/// <param name="zap2Id">Zap2It id</param>
/// <param name="languageAbbreviation">The language abbreviation.</param>
/// <param name="mirror">The mirror to use.</param>
/// <returns>The Series belonging to the provided id.</returns>
/// <remarks>
/// It is not allowed to provide both imdb and zap2it id, this will lead to a null value as return value.
/// </remarks>
/// <example>Shows how the get a series by imdb and zap2 Id.
/// <code>
/// namespace Docunamespace
/// {
/// /// <summary>
/// /// Class for the docu.
/// /// </summary>
/// class DocuClass
/// {
/// /// <summary>
/// /// Gets series by id.
/// /// </summary>
/// public List<Series> GetSeries(string imdbId, string zap2Id, Mirror mirror, Language language)
/// {
/// string apiKey = "ABCD12345";
/// TVDB.Web.ITvDb instance = new TVDB.Web.WebInterface(apiKey);
/// List<Series> series = await instance.GetSeriesByRemoteId(imdbId, zap2Id, language.Abbreviation, mirror);
///
/// return series;
/// }
/// }
/// }
/// </code>
/// </example>
public async Task<List<Series>> GetSeriesByRemoteId(string imdbId, string zap2Id, string languageAbbreviation, Mirror mirror)
{
if (string.IsNullOrEmpty(imdbId) && string.IsNullOrEmpty(zap2Id))
{
return null;
}
if (!string.IsNullOrEmpty(imdbId) && !string.IsNullOrEmpty(zap2Id))
{
return null;
}
if (mirror == null)
{
return null;
}
if (string.IsNullOrEmpty(languageAbbreviation))
{
return null;
}
string url = "{0}/api/GetSeriesByRemoteID.php?imdbid={1}&language={2}&zap2it={3}";
byte[] result = await this.client.DownloadDataTaskAsync(string.Format(url, mirror.Address, imdbId, languageAbbreviation, zap2Id)).ConfigureAwait(continueOnCapturedContext: false);
MemoryStream resultStream = new MemoryStream(result);
XmlDocument doc = new XmlDocument();
doc.Load(resultStream);
XmlNode dataNode = doc.ChildNodes[1];
List<Series> series = new List<Series>();
foreach (XmlNode currentNode in dataNode.ChildNodes)
{
Series deserialized = new Series();
deserialized.Deserialize(currentNode);
series.Add(deserialized);
}
return series;
}
示例2: GetSeriesByName
/// <summary>
/// Gets all series that match with the provided name.
/// </summary>
/// <param name="name">Name of the series.</param>
/// <param name="languageAbbreviation">Abbreviation of the language to search the series.</param>
/// <param name="mirror">The mirror to use.</param>
/// <returns>List of series that matches the provided name.</returns>
/// <example>Shows how to get a series by name.
/// <code>
/// namespace Docunamespace
/// {
/// /// <summary>
/// /// Class for the docu.
/// /// </summary>
/// class DocuClass
/// {
/// /// <summary>
/// /// Gets series by name.
/// /// </summary>
/// public List<Series> GetSeries(string name, Mirror mirror, Language language)
/// {
/// string apiKey = "ABCD12345";
/// TVDB.Web.ITvDb instance = new TVDB.Web.WebInterface(apiKey);
/// List<Series> series = await instance.GetSeriesByName(name, language.Abbreviation, mirror);
///
/// return series;
/// }
/// }
/// }
/// </code>
/// </example>
public async Task<List<Series>> GetSeriesByName(string name, string languageAbbreviation, Mirror mirror)
{
if (string.IsNullOrEmpty(name))
{
return null;
}
if (mirror == null)
{
return null;
}
if (string.IsNullOrEmpty(languageAbbreviation))
{
return null;
}
string url = "{0}/api/GetSeries.php?seriesname={1}&language={2}";
byte[] result = await this.client.DownloadDataTaskAsync(string.Format(url, mirror.Address, name, languageAbbreviation)).ConfigureAwait(continueOnCapturedContext: false);
MemoryStream resultStream = new MemoryStream(result);
XmlDocument doc = new XmlDocument();
doc.Load(resultStream);
XmlNode dataNode = doc.ChildNodes[1];
List<Series> series = new List<Series>();
foreach (XmlNode currentNode in dataNode.ChildNodes)
{
Series deserialized = new Series();
deserialized.Deserialize(currentNode);
series.Add(deserialized);
}
return series.Where(x => x.Language.Equals(languageAbbreviation)).ToList<Series>();
}