本文整理汇总了C#中RunMode.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# RunMode.ToString方法的具体用法?C# RunMode.ToString怎么用?C# RunMode.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RunMode
的用法示例。
在下文中一共展示了RunMode.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(RunMode mode, int value)
{
var stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
try
{
DatabaseFactory.CreateMetaDb();
LogUtil.Log("----------------------------------");
LogUtil.Log("Starting: " + DateTime.Now);
LogUtil.Log("MODE: " + mode.ToString());
if (mode == RunMode.Oid)
LogUtil.Log("OID: " + value);
var tmDbSync = new TmDbSync();
var tmDbMatch = new TmDbMatch();
var tmDbRename = new TmDbRename();
var tvDbSync = new TvDbSync();
var tvDbMatch = new TvDbMatch();
var tvDbRename = new TvDbRename();
var recordData = new RecordingData();
List<Recording> records = null;
if (mode != RunMode.Oid)
records = recordData.GetRecordings().ToList();
else
records = new[] { recordData.GetRecording(value) }.ToList();
if (mode == RunMode.Failed)
{
//var matches = MatchData.GetMatches().Where(a => !a.Success);
//records = records.Where(a => matches.Any(b => b.Oid == a.Oid)).ToList();
var successes = MatchData.GetMatches().Where(a => a.Success);
records = records.Where(a => !successes.Any(b => b.Oid == a.Oid)).ToList();
}
//Sync
foreach (var record in records)
{
try
{
if (!record.IsMovie)
tvDbSync.Sync(record);
else
tmDbSync.Sync(record);
}
catch (Exception ex)
{
LogUtil.Log("Synchronization Error");
LogUtil.Log(ex.Message);
}
}
//Match & Rename
foreach (var record in records)
{
string targetId = null;
try
{
if (!record.IsMovie)
{
float best = -1f;
var result = tvDbMatch.Match(record, out best);
var series = result.Item1;
var episode = result.Item2;
tvDbRename.Rename(record, series, episode);
targetId = episode != null ? episode.Id : null; //save target id
}
else
{
float best = -1f;
var movie = tmDbMatch.Match(record, out best);
tmDbRename.Rename(record, movie);
targetId = movie != null ? movie.Id : null; //save target id
}
}
finally
{
//Record success/failure
var oid = record.Oid;
var type = record.IsMovie ? MediaType.MovieType : MediaType.SeriesType;
var success = targetId != null;
MatchData.SaveMatch(new Match(oid, type, success, targetId));
}
}
}
catch (Exception ex)
{
LogUtil.Log("Critical Error");
LogUtil.Log(ex.Message);
LogUtil.Log(ex.StackTrace.ToString());
}
LogUtil.Log("Finished: " + DateTime.Now);
LogUtil.Log("Ellapsed Time: " + (stopwatch.ElapsedMilliseconds / 1000) + " seconds");
LogUtil.Log("----------------------------------");
}
示例2: RunWithDebugger
internal bool RunWithDebugger(string scriptPath, RunMode runMode)
{
// The caller should make sure before calling this!
System.Diagnostics.Debug.Assert(false == this.IsBusy);
if (false != this.IsBusy)
return false;
// The script is executed without a debugger attached,
// therefore this call does not make sense right now.
if (null != scriptRunner)
return false;
Logger.LogInfo("RunWithDebugger", "RunMode: " + runMode.ToString());
if (Solution.Current.ActiveScript != null)
{
ITextBuffer textBuffer = Solution.Current.ActiveScript.GetTextBuffer();
if (null != textBuffer)
Logger.LogInfo("TextEditorControl-Run-Script", textBuffer.GetContent());
}
workerParams.ExecutionEnded = true;
workerParams.RequestedRunMode = runMode;
if (null == debugRunner)
{
// If debug session has not started, attempt to attach to the debugger.
// If that fails, then we aren't quite ready for debugging, just yet.
if (this.SetupDebugRunner(scriptPath) == false)
return false; // Fail to start debugger for some reason.
// Okay the first press of "Run (Debug)" button does nothing but
// single step through the script. So if this is the first press
// of "Run (Debug)" button, then turn it into a single-step instead.
//
workerParams.RequestedRunMode = RunMode.StepNext;
}
workerParams.ExecutionEnded = false;
SetExecutionState(ExecutionStateChangedEventArgs.States.Debugging);
if (false == this.asynchronousExecution) // Normal execution requested.
{
RunWithDebuggerGuts();
RunWithDebuggerFinalized();
return ((null != workerParams.CurrentVmState) && (!workerParams.ExecutionEnded));
}
else // Asynchronous execution requested.
{
if (null == internalWorker)
{
internalWorker = new BackgroundWorker();
internalWorker.DoWork += new DoWorkEventHandler(RunWithDebuggerTask);
internalWorker.RunWorkerCompleted += RunWithDebuggerTaskCompleted;
}
// Place the application into a debugging mode.
internalWorker.RunWorkerAsync();
return true; // Always return 'true' when it gets here.
}
}