forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptResult.cs
More file actions
64 lines (50 loc) · 1.88 KB
/
ScriptResult.cs
File metadata and controls
64 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.ExceptionServices;
namespace ScriptCs.Contracts
{
public class ScriptResult
{
private readonly HashSet<string> _invalidNamespaces = new HashSet<string>();
public static readonly ScriptResult Empty = new ScriptResult();
public static readonly ScriptResult Incomplete = new ScriptResult { IsCompleteSubmission = false };
public ScriptResult()
{
// Explicit default ctor to use as mock return value.
IsCompleteSubmission = true;
}
public ScriptResult(
object returnValue = null,
Exception executionException = null,
Exception compilationException = null,
IEnumerable<string> invalidNamespaces = null)
{
if (returnValue != null)
{
ReturnValue = returnValue;
}
if (executionException != null)
{
ExecuteExceptionInfo = ExceptionDispatchInfo.Capture(executionException);
}
if (compilationException != null)
{
CompileExceptionInfo = ExceptionDispatchInfo.Capture(compilationException);
}
if (invalidNamespaces != null)
{
foreach (var ns in invalidNamespaces.Distinct())
{
_invalidNamespaces.Add(ns);
}
}
IsCompleteSubmission = true;
}
public object ReturnValue { get; private set; }
public ExceptionDispatchInfo ExecuteExceptionInfo { get; private set; }
public ExceptionDispatchInfo CompileExceptionInfo { get; private set; }
public IEnumerable<string> InvalidNamespaces => _invalidNamespaces.ToArray();
public bool IsCompleteSubmission { get; private set; }
}
}