-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRozkaz.cs
67 lines (59 loc) · 1.9 KB
/
Rozkaz.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace POSK
{
[Serializable()]
public class Rozkaz : ISerializable
{
public int operacja;
public Rejestr arg1 = new Rejestr();
public Object arg2 = new Object();
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("operacja", operacja);
info.AddValue("arg1", arg1);
info.AddValue("arg2", arg2);
}
public Rozkaz() { }
public Rozkaz(SerializationInfo info, StreamingContext ctxt)
{
//Get the values from info and assign them to the properties
operacja = (int)info.GetValue("operacja", typeof(int));
arg1 = (Rejestr)info.GetValue("arg1", typeof(Rejestr));
arg2 = (Object)info.GetValue("Height", typeof(Object));
}
public String tekstRozkazu()
{
String rozkaz = "";
String argument = "";
switch (operacja)
{
case 0:
{
rozkaz = "MOV";
}break;
case 1:
{
rozkaz = "ADD";
}
break;
case 2:
{
rozkaz = "SUB";
}
break;
default: { return "Operacja nieznana \r\n"; }
}
short i = 0;
if (Int16.TryParse(arg2.ToString(), out i))
argument = i.ToString();
else
argument = ((Rejestr)arg2).getNazwa();
return rozkaz + " " + arg1.getNazwa() + " " + argument + "\r\n";
}
}
}