TraceLab Component Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
RScriptResult.cs
Go to the documentation of this file.
1 // RPlugin - A framework for running R scripts in .NET
2 // Copyright © 2012-2013 SEMERU
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Linq;
20 using System.Text;
21 using System.Diagnostics;
22 
23 namespace RPlugin.Core
24 {
29  public class RScriptResult
30  {
34  public string Output
35  {
36  get
37  {
38  return ScriptOutput.ToString();
39  }
40  internal set
41  {
42  ScriptOutput = new StringBuilder(value);
43  }
44  }
45 
49  public string Error
50  {
51  get
52  {
53  return ScriptError.ToString();
54  }
55  internal set
56  {
57  ScriptError = new StringBuilder(value);
58  }
59  }
60 
64  public int ExitCode { get; internal set; }
65 
66  private StringBuilder ScriptOutput;
67  private StringBuilder ScriptError;
68 
69  internal RScriptResult()
70  {
71  ScriptOutput = new StringBuilder();
72  ScriptError = new StringBuilder();
73  ExitCode = 0;
74  }
75 
82  internal RScriptResult(string output, string error, int exit)
83  {
84  Output = output;
85  Error = error;
86  ExitCode = exit;
87  }
88 
89 
90  internal void ScriptOutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
91  {
92  if (!String.IsNullOrEmpty(outLine.Data))
93  {
94  ScriptOutput.Append(outLine.Data);
95  }
96  }
97 
98  internal void ScriptErrorHandler(object sendingProcess, DataReceivedEventArgs outLine)
99  {
100  if (!String.IsNullOrEmpty(outLine.Data))
101  {
102  ScriptError.Append(outLine.Data);
103  }
104  }
105  }
106 }