本文整理汇总了C#中ILogger.WriteEntry方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.WriteEntry方法的具体用法?C# ILogger.WriteEntry怎么用?C# ILogger.WriteEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.WriteEntry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Grab
public override List<Show> Grab(string xmlParameters, ILogger logger)
{
logger.WriteEntry("Started sky.it grab", LogType.Info);
var selectedChannels = new List<Channel>();
var shows = new List<Show>();
if (!string.IsNullOrEmpty(xmlParameters))
{
var doc = XDocument.Parse(xmlParameters);
foreach (var c in doc.Descendants("Channel"))
selectedChannels.Add((Channel)Enum.Parse(typeof(Channel), c.Value));
}
if (selectedChannels.Count == 0) // no channel specified , lets take all available channels
foreach (Channel c in Enum.GetValues(typeof(Channel)))
selectedChannels.Add(c);
foreach (var c in selectedChannels)
{
var p = new GrabParameters();
p.Channel = c;
var channelShows = Grab(p, logger).OrderBy(x => x.StartTime).ToList() ;
FixShowsEndTimeByStartTime(channelShows);
shows.AddRange(channelShows);
}
logger.WriteEntry("Finshed sky.it grab", LogType.Info);
return shows;
}
示例2: TranslateShows
public void TranslateShows(List<Show> shows, Language sourceLang, Language targetLang, ILogger logger)
{
Debug.WriteLine("Found {0} Shows", shows.Count);
Debug.WriteLine("Started Translating...");
int counter = 0;
var lockObject = new object();
var lastTime = DateTime.Now;
Parallel.ForEach(shows, new ParallelOptions() { MaxDegreeOfParallelism = 8 }, show =>
{
show.Title = Tools.CleanupText(Translate(sourceLang, targetLang, show.Title));
if (!string.IsNullOrEmpty(show.Description))
show.Description = Tools.CleanupText(Translate(sourceLang, targetLang, show.Description));
lock (lockObject)
{
counter++;
}
if (DateTime.Now - lastTime > TimeSpan.FromSeconds(30))
{
lastTime = DateTime.Now;
var text = string.Format("Translator Finished {0}/{1} {2:0.00}%", counter, shows.Count, counter * 100.0 / shows.Count);
Debug.WriteLine(text);
lock (lockObject)
logger.WriteEntry(text, LogType.Info);
}
}
);
Cache.SaveCache();
Debug.WriteLine("Finished Translating.");
}