blob: 2ba4a74cd9451a655e171222b6a87cf601c46861 (
plain)
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
65
66
67
|
using Google.Protobuf;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tango.Integration.Operation;
using Tango.Scripting.Basic;
using Tango.Transport;
namespace Tango.FSE.Stubs
{
public class TestProject : Project<TestContext>
{
private static JsonSerializerSettings _jsonSettings;
public ObservableCollection<TestInput> Inputs { get; set; }
static TestProject()
{
_jsonSettings = new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.Auto,
PreserveReferencesHandling = PreserveReferencesHandling.All,
};
}
public TestProject() : base()
{
Inputs = new ObservableCollection<TestInput>();
}
public static TestProject New(String name)
{
TestProject project = new TestProject();
project.Name = name;
project.Scripts.Add(Script.New("Program.csx", Encoding.UTF8.GetString(Properties.Resources.main_template), true));
project.Scripts.Add(Script.New("Service.csx", Encoding.UTF8.GetString(Properties.Resources.lib_template).Replace("@LibraryName", "Service")));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(String)));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(Enumerable)));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(Form)));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(TestProject)));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(PMR.Common.MessageType)));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(ITransporter)));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(IMachineOperator)));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(IMessage)));
project.ReferenceAssemblies.Add(ReferenceAssembly.FromType(typeof(System.Drawing.Point)));
return project;
}
public String ToJson()
{
return JsonConvert.SerializeObject(this, _jsonSettings);
}
public static TestProject FromJson(String json)
{
return JsonConvert.DeserializeObject<TestProject>(json, _jsonSettings);
}
}
}
|