protected internal StackItem Convert(object value) { return(value switch { null => StackItem.Null, bool b => b, sbyte i => i, byte i => (BigInteger)i, short i => i, ushort i => (BigInteger)i, int i => i, uint i => i, long i => i, ulong i => i, Enum e => Convert(System.Convert.ChangeType(e, e.GetTypeCode())), byte[] data => data, string s => s, BigInteger i => i, IInteroperable interoperable => interoperable.ToStackItem(ReferenceCounter), ISerializable i => i.ToArray(), StackItem item => item, (object a, object b) => new Struct(ReferenceCounter) { Convert(a), Convert(b) }, Array array => new VMArray(ReferenceCounter, array.OfType <object>().Select(p => Convert(p))), _ => StackItem.FromInterface(value) });
void IInteroperable.FromReplica(IInteroperable replica) { TrimmedBlock from = (TrimmedBlock)replica; Header = from.Header; Hashes = from.Hashes; }
void IInteroperable.FromReplica(IInteroperable replica) { ContractState from = (ContractState)replica; Id = from.Id; UpdateCounter = from.UpdateCounter; Hash = from.Hash; Nef = from.Nef; Manifest = from.Manifest; }
public T GetInteroperable <T>() where T : IInteroperable, new() { if (interoperable is null) { interoperable = new T(); interoperable.FromStackItem(BinarySerializer.Deserialize(value, 16, 34)); } value = null; return((T)interoperable); }
void IInteroperable.FromReplica(IInteroperable replica) { TransactionState from = (TransactionState)replica; BlockIndex = from.BlockIndex; Transaction = from.Transaction; State = from.State; if (_rawTransaction.IsEmpty) { _rawTransaction = from._rawTransaction; } }
private StackItem ConvertReturnValue(object value) { return(value switch { null => StackItem.Null, bool b => b, sbyte i => i, byte i => (BigInteger)i, short i => i, ushort i => (BigInteger)i, int i => i, uint i => i, long i => i, ulong i => i, Enum e => ConvertReturnValue(Convert.ChangeType(e, e.GetTypeCode())), byte[] data => data, string s => s, UInt160 i => i.ToArray(), UInt256 i => i.ToArray(), IInteroperable interoperable => interoperable.ToStackItem(ReferenceCounter), IInteroperable[] array => new VMArray(ReferenceCounter, array.Select(p => p.ToStackItem(ReferenceCounter))), StackItem item => item, _ => StackItem.FromInterface(value) });
public void NetTypes( bool p1, sbyte p2, byte p3, short p4, ushort p5, int p6, uint p7, long p8, ulong p9, BigInteger p10, byte[] p11, string p12, IInteroperable p13, ISerializable p14, int[] p15, ContractParameterType p16, object p17) { }
public StorageItem(IInteroperable interoperable, bool isConstant = false) { this.interoperable = interoperable; this.IsConstant = isConstant; }