本文整理汇总了C#中System.Xml.Linq.XDocument.GetSeriesData方法的典型用法代码示例。如果您正苦于以下问题:C# XDocument.GetSeriesData方法的具体用法?C# XDocument.GetSeriesData怎么用?C# XDocument.GetSeriesData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XDocument
的用法示例。
在下文中一共展示了XDocument.GetSeriesData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildShow
private static Show BuildShow(XDocument doc)
{
return new Show {
ID = doc.GetSeriesData("id"),
ImdbID = doc.GetSeriesData("IMDB_ID"),
Name = doc.GetSeriesData("SeriesName"),
Language = doc.GetSeriesData("Language"),
Network = doc.GetSeriesData("Network"),
Description = doc.GetSeriesData("Overview"),
Rating = string.IsNullOrWhiteSpace(doc.GetSeriesData("Rating"))
? (double?)null
: Convert.ToDouble(doc.GetSeriesData("Rating"),
System.Globalization.CultureInfo.InvariantCulture),
RatingCount = string.IsNullOrWhiteSpace(doc.GetSeriesData("RatingCount"))
? 0
: Convert.ToInt32(doc.GetSeriesData("RatingCount")),
Runtime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Runtime"))
? (int?)null
: Convert.ToInt32(doc.GetSeriesData("Runtime")),
Banner = doc.GetSeriesData("banner"),
Fanart = doc.GetSeriesData("fanart"),
LastUpdated = string.IsNullOrWhiteSpace(doc.GetSeriesData("lastupdated"))
? (long?)null
: Convert.ToInt64(doc.GetSeriesData("lastupdated")),
Poster = doc.GetSeriesData("poster"),
Zap2ItID = doc.GetSeriesData("zap2it_id"),
FirstAired = Utils.ParseDate(doc.GetSeriesData("FirstAired")),
AirTime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_Time"))
? (TimeSpan?)null
: Utils.ParseTime(doc.GetSeriesData("Airs_Time")),
AirDay = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_DayOfWeek"))
? (DayOfWeek?)null
: (DayOfWeek)Enum.Parse(typeof(DayOfWeek), doc.GetSeriesData("Airs_DayOfWeek")),
Status = string.IsNullOrWhiteSpace(doc.GetSeriesData("Status"))
? Status.Unknown
: (Status)Enum.Parse(typeof(Status), doc.GetSeriesData("Status")),
ContentRating = Utils.GetContentRating(doc.GetSeriesData("ContentRating")),
Genres = new List<string>(doc.GetSeriesData("Genre").Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)),
Actors = new List<string>(doc.GetSeriesData("Actors").Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)),
Episodes = BuildEpisodes(doc)
};
}
示例2: ShowBuilder
public ShowBuilder(XDocument doc)
{
_show = doc.Root
.Elements("Series")
.Select(show => new Show
{
Id = int.Parse(show.Attribute("id").ToString()),
ImdbId = show.Attribute("IMDB_ID").ToString(),
Name = show.Attribute("SeriesName").ToString(),
Language = show.Attribute("Language").ToString(),
Network = show.Attribute("Network").ToString(),
Description = show.Attribute("Overview").ToString(),
Rating = string.IsNullOrWhiteSpace(show.Attribute("Rating").ToString())
? (double?)null
: Convert.ToDouble(show.Attribute("Rating").ToString(), CultureInfo.InvariantCulture),
RatingCount = string.IsNullOrWhiteSpace(show.Attribute("RatingCount").ToString())
? 0
: Convert.ToInt32(show.Attribute("RatingCount").ToString()),
Runtime = string.IsNullOrWhiteSpace(show.Attribute("Runtime").ToString())
? 0
: Convert.ToInt32(show.Attribute("Runtime").ToString()),
Banner = GetBannerUri(show.Attribute("banner").ToString()),
Fanart = GetBannerUri(show.Attribute("fanart").ToString()),
LastUpdated = string.IsNullOrWhiteSpace(show.Attribute("lastupdated").ToString())
? (long?)null
: Convert.ToInt64(show.Attribute("lastupdated").ToString()),
Poster = GetBannerUri(show.Attribute("poster").ToString()),
Zap2ItID = show.Attribute("zap2it_id").ToString(),
FirstAired = string.IsNullOrWhiteSpace(show.Attribute("FirstAired").ToString())
? (DateTime?)null
: DateTime.ParseExact(show.Attribute("FirstAired").ToString(), "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal)
})
.FirstOrDefault();
_show = new Show();
_show.Id = int.Parse(doc.GetSeriesData("id"));
_show.ImdbId = doc.GetSeriesData("IMDB_ID");
_show.Name = doc.GetSeriesData("SeriesName");
_show.Language = doc.GetSeriesData("Language");
_show.Network = doc.GetSeriesData("Network");
_show.Description = doc.GetSeriesData("Overview");
_show.Rating = string.IsNullOrWhiteSpace(doc.GetSeriesData("Rating"))
? (double?) null
: Convert.ToDouble(doc.GetSeriesData("Rating"),
System.Globalization.CultureInfo.InvariantCulture);
_show.RatingCount = string.IsNullOrWhiteSpace(doc.GetSeriesData("RatingCount"))
? 0
: Convert.ToInt32(doc.GetSeriesData("RatingCount"));
_show.Runtime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Runtime"))
? (int?) null
: Convert.ToInt32(doc.GetSeriesData("Runtime"));
_show.Banner = GetBannerUri(doc.GetSeriesData("banner"));
_show.Fanart = GetBannerUri(doc.GetSeriesData("fanart"));
_show.LastUpdated = string.IsNullOrWhiteSpace(doc.GetSeriesData("lastupdated"))
? (long?) null
: Convert.ToInt64(doc.GetSeriesData("lastupdated"));
_show.Poster = GetBannerUri(doc.GetSeriesData("poster"));
_show.Zap2ItID = doc.GetSeriesData("zap2it_id");
_show.FirstAired = string.IsNullOrWhiteSpace(doc.GetSeriesData("FirstAired"))
? (DateTime?) null
: Utils.ParseDate(doc.GetSeriesData("FirstAired"));
_show.AirTime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_Time"))
? (TimeSpan?) null
: Utils.ParseTime(doc.GetSeriesData("Airs_Time"));
_show.AirDay = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_DayOfWeek"))
? (Frequency?) null
: (Frequency) Enum.Parse(typeof (Frequency), doc.GetSeriesData("Airs_DayOfWeek"));
_show.Status = string.IsNullOrWhiteSpace(doc.GetSeriesData("Status"))
? Status.Unknown
: (Status) Enum.Parse(typeof (Status), doc.GetSeriesData("Status"));
_show.ContentRating = Utils.GetContentRating(doc.GetSeriesData("ContentRating"));
_show.Genres =
new List<string>(doc.GetSeriesData("Genre")
.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries));
_show.Actors =
new List<string>(doc.GetSeriesData("Actors")
.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries));
_show.Episodes = new EpisodesBuilder(doc).BuildEpisodes();
}