This repository was archived by the owner on Feb 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathLedgerEntry.cs
120 lines (114 loc) · 4.29 KB
/
LedgerEntry.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten
namespace Stellar.Generated
{
// === xdr source ============================================================
// struct LedgerEntry
// {
// uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed
//
// union switch (LedgerEntryType type)
// {
// case ACCOUNT:
// AccountEntry account;
// case TRUSTLINE:
// TrustLineEntry trustLine;
// case OFFER:
// OfferEntry offer;
// case DATA:
// DataEntry data;
// }
// data;
//
// // reserved for future use
// union switch (int v)
// {
// case 0:
// void;
// }
// ext;
// };
// ===========================================================================
public class LedgerEntry {
public LedgerEntry () {}
public Uint32 LastModifiedLedgerSeq { get; set; }
public LedgerEntryData Data { get; set; }
public LedgerEntryExt Ext { get; set; }
public static void Encode(IByteWriter stream, LedgerEntry encodedLedgerEntry) {
Uint32.Encode(stream, encodedLedgerEntry.LastModifiedLedgerSeq);
LedgerEntryData.Encode(stream, encodedLedgerEntry.Data);
LedgerEntryExt.Encode(stream, encodedLedgerEntry.Ext);
}
public static LedgerEntry Decode(IByteReader stream) {
LedgerEntry decodedLedgerEntry = new LedgerEntry();
decodedLedgerEntry.LastModifiedLedgerSeq = Uint32.Decode(stream);
decodedLedgerEntry.Data = LedgerEntryData.Decode(stream);
decodedLedgerEntry.Ext = LedgerEntryExt.Decode(stream);
return decodedLedgerEntry;
}
public class LedgerEntryData {
public LedgerEntryData () {}
public LedgerEntryType Discriminant { get; set; } = new LedgerEntryType();
public AccountEntry Account { get; set; } = default(AccountEntry);
public TrustLineEntry TrustLine { get; set; } = default(TrustLineEntry);
public OfferEntry Offer { get; set; } = default(OfferEntry);
public DataEntry Data { get; set; } = default(DataEntry);
public static void Encode(IByteWriter stream, LedgerEntryData encodedLedgerEntryData) {
XdrEncoding.EncodeInt32((int)encodedLedgerEntryData.Discriminant.InnerValue, stream);
switch (encodedLedgerEntryData.Discriminant.InnerValue) {
case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
AccountEntry.Encode(stream, encodedLedgerEntryData.Account);
break;
case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
TrustLineEntry.Encode(stream, encodedLedgerEntryData.TrustLine);
break;
case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
OfferEntry.Encode(stream, encodedLedgerEntryData.Offer);
break;
case LedgerEntryType.LedgerEntryTypeEnum.DATA:
DataEntry.Encode(stream, encodedLedgerEntryData.Data);
break;
}
}
public static LedgerEntryData Decode(IByteReader stream) {
LedgerEntryData decodedLedgerEntryData = new LedgerEntryData();
decodedLedgerEntryData.Discriminant = LedgerEntryType.Decode(stream);
switch (decodedLedgerEntryData.Discriminant.InnerValue) {
case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
decodedLedgerEntryData.Account = AccountEntry.Decode(stream);
break;
case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
decodedLedgerEntryData.TrustLine = TrustLineEntry.Decode(stream);
break;
case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
decodedLedgerEntryData.Offer = OfferEntry.Decode(stream);
break;
case LedgerEntryType.LedgerEntryTypeEnum.DATA:
decodedLedgerEntryData.Data = DataEntry.Decode(stream);
break;
}
return decodedLedgerEntryData;
}
}
public class LedgerEntryExt {
public LedgerEntryExt () {}
public int Discriminant { get; set; } = new int();
public static void Encode(IByteWriter stream, LedgerEntryExt encodedLedgerEntryExt) {
XdrEncoding.EncodeInt32(encodedLedgerEntryExt.Discriminant, stream);
switch (encodedLedgerEntryExt.Discriminant) {
case 0:
break;
}
}
public static LedgerEntryExt Decode(IByteReader stream) {
LedgerEntryExt decodedLedgerEntryExt = new LedgerEntryExt();
decodedLedgerEntryExt.Discriminant = XdrEncoding.DecodeInt32(stream);
switch (decodedLedgerEntryExt.Discriminant) {
case 0:
break;
}
return decodedLedgerEntryExt;
}
}
}
}