本文整理汇总了C#中System.Xml.XmlReader.ReadStringSafe方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadStringSafe方法的具体用法?C# XmlReader.ReadStringSafe怎么用?C# XmlReader.ReadStringSafe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadStringSafe方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchCast
/// <summary>
/// Fetches from the cast node
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="info">The info.</param>
private static void FetchCast(XmlReader reader, TrailerInfo info)
{
reader.MoveToContent();
reader.Read();
while (reader.IsStartElement())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "name":
info.Video.AddPerson(new PersonInfo { Name = reader.ReadStringSafe(), Type = PersonType.Actor });
break;
default:
reader.Skip();
break;
}
}
}
}
示例2: FetchPosterUrl
/// <summary>
/// Fetches from the poster node
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="info">The info.</param>
private static void FetchPosterUrl(XmlReader reader, TrailerInfo info)
{
reader.MoveToContent();
reader.Read();
while (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "location":
info.ImageUrl = reader.ReadStringSafe();
break;
case "xlarge":
info.HdImageUrl = reader.ReadStringSafe();
break;
default:
reader.Skip();
break;
}
}
}
示例3: FetchGenres
/// <summary>
/// Fetches from the genre node
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="info">The info.</param>
private static void FetchGenres(XmlReader reader, TrailerInfo info)
{
reader.MoveToContent();
reader.Read();
while (reader.IsStartElement())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "name":
info.Video.AddGenre(reader.ReadStringSafe());
break;
default:
reader.Skip();
break;
}
}
}
}
示例4: FetchInfo
/// <summary>
/// Fetches from the info node
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="info">The info.</param>
private static void FetchInfo(XmlReader reader, TrailerInfo info)
{
reader.MoveToContent();
reader.Read();
while (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "title":
info.Video.Name = reader.ReadStringSafe();
break;
case "runtime":
{
var runtime = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(runtime))
{
if (runtime.StartsWith(":", StringComparison.OrdinalIgnoreCase))
{
runtime = "0" + runtime;
}
TimeSpan runtimeTimeSpan;
if (TimeSpan.TryParse(runtime, UsCulture, out runtimeTimeSpan))
{
info.Video.OriginalRunTimeTicks = runtimeTimeSpan.Ticks;
}
}
break;
}
case "rating":
{
var rating = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(rating) && !string.Equals("not yet rated", rating, StringComparison.OrdinalIgnoreCase))
{
info.Video.OfficialRating = rating;
}
break;
}
case "studio":
{
var studio = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(studio))
{
info.Video.AddStudio(studio);
}
break;
}
case "postdate":
{
DateTime date;
if (DateTime.TryParse(reader.ReadStringSafe(), UsCulture, DateTimeStyles.None, out date))
{
info.PostDate = date.ToUniversalTime();
}
break;
}
case "releasedate":
{
var val = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(val))
{
DateTime date;
if (DateTime.TryParse(val, UsCulture, DateTimeStyles.None, out date))
{
info.Video.PremiereDate = date.ToUniversalTime();
info.Video.ProductionYear = date.Year;
}
}
break;
}
case "director":
{
var directors = reader.ReadStringSafe() ?? string.Empty;
foreach (var director in Split(directors, ',', StringSplitOptions.RemoveEmptyEntries))
{
var name = director.Trim();
if (!string.IsNullOrWhiteSpace(name))
{
info.Video.AddPerson(new PersonInfo { Name = name, Type = PersonType.Director });
}
}
break;
}
case "description":
//.........这里部分代码省略.........
示例5: FetchCast
/// <summary>
/// Fetches from the cast node
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="info">The info.</param>
private static void FetchCast(XmlReader reader, TrailerInfo info)
{
reader.MoveToContent();
reader.Read();
while (reader.IsStartElement())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "name":
{
var name = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(name))
{
info.People.Add(new PersonInfo { Name = name, Type = PersonType.Actor });
}
break;
}
default:
reader.Skip();
break;
}
}
}
}
示例6: FetchGenres
/// <summary>
/// Fetches from the genre node
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="info">The info.</param>
private static void FetchGenres(XmlReader reader, TrailerInfo info)
{
reader.MoveToContent();
reader.Read();
while (reader.IsStartElement())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "name":
{
var val = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(val))
{
info.Genres.Add(val);
}
break;
}
default:
reader.Skip();
break;
}
}
}
}
示例7: FetchInfo
/// <summary>
/// Fetches from the info node
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="info">The info.</param>
private static void FetchInfo(XmlReader reader, TrailerInfo info, ILogger logger)
{
reader.MoveToContent();
reader.Read();
while (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "title":
info.Name = reader.ReadStringSafe();
break;
case "runtime":
{
var val = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(val))
{
var parts = val.Split(':');
if (parts.Length == 2)
{
int mins;
int secs;
if (int.TryParse(parts[0], NumberStyles.Any, UsCulture, out mins) &&
int.TryParse(parts[1], NumberStyles.Any, UsCulture, out secs))
{
var totalSeconds = (mins*60) + secs;
info.RunTimeTicks = TimeSpan.FromSeconds(totalSeconds).Ticks;
}
}
}
break;
}
case "rating":
{
var rating = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(rating) && !string.Equals("not yet rated", rating, StringComparison.OrdinalIgnoreCase))
{
info.OfficialRating = rating;
}
break;
}
case "studio":
{
var studio = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(studio))
{
info.Studios.Add(studio);
}
break;
}
case "postdate":
{
DateTime date;
if (DateTime.TryParse(reader.ReadStringSafe(), UsCulture, DateTimeStyles.None, out date))
{
info.PostDate = date.ToUniversalTime();
}
break;
}
case "releasedate":
{
var val = reader.ReadStringSafe();
if (!string.IsNullOrWhiteSpace(val))
{
DateTime date;
if (DateTime.TryParse(val, UsCulture, DateTimeStyles.None, out date))
{
info.PremiereDate = date.ToUniversalTime();
info.ProductionYear = date.Year;
}
}
break;
}
case "director":
{
var directors = reader.ReadStringSafe() ?? string.Empty;
foreach (var director in Split(directors, ',', StringSplitOptions.RemoveEmptyEntries))
{
var name = director.Trim();
if (!string.IsNullOrWhiteSpace(name))
{
info.People.Add(new PersonInfo { Name = name, Type = PersonType.Director });
}
//.........这里部分代码省略.........