Exemplo n.º 1
0
 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)
     });
Exemplo n.º 2
0
        void IInteroperable.FromReplica(IInteroperable replica)
        {
            TrimmedBlock from = (TrimmedBlock)replica;

            Header = from.Header;
            Hashes = from.Hashes;
        }
Exemplo n.º 3
0
        void IInteroperable.FromReplica(IInteroperable replica)
        {
            ContractState from = (ContractState)replica;

            Id            = from.Id;
            UpdateCounter = from.UpdateCounter;
            Hash          = from.Hash;
            Nef           = from.Nef;
            Manifest      = from.Manifest;
        }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
        void IInteroperable.FromReplica(IInteroperable replica)
        {
            TransactionState from = (TransactionState)replica;

            BlockIndex  = from.BlockIndex;
            Transaction = from.Transaction;
            State       = from.State;
            if (_rawTransaction.IsEmpty)
            {
                _rawTransaction = from._rawTransaction;
            }
        }
Exemplo n.º 6
0
 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)
     });
Exemplo n.º 7
0
 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)
 {
 }
Exemplo n.º 8
0
 public StorageItem(IInteroperable interoperable, bool isConstant = false)
 {
     this.interoperable = interoperable;
     this.IsConstant    = isConstant;
 }