-
Notifications
You must be signed in to change notification settings - Fork 0
/
PSMes.cs
46 lines (37 loc) · 1002 Bytes
/
PSMes.cs
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
namespace PSMes;
using System;
using System.Management.Automation;
using Mes;
[Cmdlet(VerbsCommon.New, "Mes")]
public class ParseMes : PSCmdlet
{
[Parameter(Position=0)]
public string MesText { get; set; }
protected override void ProcessRecord()
{
MesBuilder builder = new MesBuilder(this.MesText ?? "");
var mesobj = builder.Build();
WriteObject(mesobj, true);
}
}
[Cmdlet(VerbsCommon.Get, "MesBuilder")]
public class GetMesBuilder : Cmdlet
{
[Parameter(Position = 0)]
public string? MesText { get; set; }
[Parameter(Position = 1)]
public string? File { get; set; }
protected override void ProcessRecord()
{
if (File == null)
{
MesBuilder builder = new MesBuilder(this.MesText);
WriteObject(builder, true);
}
else
{
MesBuilder builder = new MesBuilder(System.IO.File.ReadAllText(File));
WriteObject(builder, true);
}
}
}