-
Notifications
You must be signed in to change notification settings - Fork 1
/
ReadAvtomateCommand.cs
45 lines (39 loc) · 1.37 KB
/
ReadAvtomateCommand.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace AutomataConverter
{
class ReadAvtomateCommand : ICommand
{
private AutomataConverterApplication app;
public string Help { get { return "Считывает автомат из файла"; } }
public string Name { get { return "read"; } }
public void Execute(params string[] parameters)
{
try
{
var name = parameters[0];
var path = parameters[1];
TableToAutomateConverter ttac = new TableToAutomateConverter();
NamedAutomaton na = ttac.ReadAutomate(path);
app.Storage.AddAutomate(name, na);
}
catch (IndexOutOfRangeException e)
{
Console.WriteLine("Слишком мало параметров команды");
}
catch (FileNotFoundException e)
{
Console.WriteLine("Файл '{0}' не найден", parameters[1]);
}
}
public string Description { get { return "read имя путь"; } }
public string[] Synonyms { get { return new string[]{"get"}; } }
public ReadAvtomateCommand(AutomataConverterApplication app)
{
this.app = app;
}
}
}