コード例 #1
0
ファイル: Player.cs プロジェクト: dibrov4bor/Competitive-Test
 public void AddRecord(LogRecord record)
 {
     if (dispatcher == null) {
     log.Add(record);
       } else {
     dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => log.Add(record)));
       }
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: dibrov4bor/Competitive-Test
 /// <summary>
 /// Makes a single turn utilizing the communicator and recording results
 /// </summary>
 /// <param name="input">Input string</param>
 /// <param name="timeLimit">Time limit</param>
 /// <returns>Log record with the execution outcome</returns>
 public LogRecord Turn(String input, TimeSpan timeLimit)
 {
     AddRecord(LogRecord.Make(input.Trim(), RecordClass.JudgeToPlayer));
       LogRecord record;
       try {
     RunOutcome ro = communicator.Run(input, timeLimit);
     record = new LogRecord(ro.Output.Trim(), RecordClass.PlayerToJudge, ro.Elapsed, ro.TimeStamp);
     Status = "OK";
       } catch (RuntimeErrorException ex) {
     record = LogRecord.Make(String.Format("Runtime Error #{0}", ex.ErrorCode), RecordClass.Error);
     Status = "RE";
       } catch (TimeLimitException) {
     record = LogRecord.Make("Time Limit has been exceeded", RecordClass.Error);
     Status = "TL";
       } catch (Exception) {
     record = LogRecord.Make("Communication has failed", RecordClass.Error);
     Path = null;
       }
       AddRecord(record);
       return record;
 }