Пример #1
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 /// <param name="protoName">The protounit.</param>
 /// <param name="type">The item type.</param>
 /// <param name="item">The item name.</param>
 /// <param name="result">The result.</param>
 public PacketBResponseBuyItem(string protoName, InventoryItemTypes type, string item, byte result)
 {
     ProtoName = protoName;
     Type      = type;
     Item      = item;
     Result    = result;
 }
Пример #2
0
        public static InventoryItem decodeInventoryItem(byte[] bytes)
        {
            InventoryItemTypes type = (InventoryItemTypes)bytes.GetIxiVarInt(0).num;
            InventoryItem      item = null;

            switch (type)
            {
            case InventoryItemTypes.block:
                item = new InventoryItemBlock(bytes);
                break;

            case InventoryItemTypes.transaction:
                item = new InventoryItem(bytes);
                break;

            case InventoryItemTypes.keepAlive:
                item = new InventoryItemKeepAlive(bytes);
                break;

            case InventoryItemTypes.blockSignature:
                item = new InventoryItemSignature(bytes);
                break;
            }
            return(item);
        }
Пример #3
0
 private bool remove(InventoryItemTypes type, byte[] hash)
 {
     lock (inventory)
     {
         return(inventory[type].Remove(hash));
     }
 }
Пример #4
0
 public PendingInventoryItem get(InventoryItemTypes type, byte[] hash)
 {
     lock (inventory)
     {
         var inventory_types = inventory[type];
         if (!inventory_types.ContainsKey(hash))
         {
             return(null);
         }
         return(inventory_types[hash]);
     }
 }
Пример #5
0
        public InventoryItem(byte[] bytes)
        {
            using (MemoryStream m = new MemoryStream(bytes))
            {
                using (BinaryReader reader = new BinaryReader(m))
                {
                    type = (InventoryItemTypes)reader.ReadIxiVarInt();

                    int hash_len = (int)reader.ReadIxiVarUInt();
                    hash = reader.ReadBytes(hash_len);
                }
            }
        }
Пример #6
0
        protected void truncateInventory(InventoryItemTypes type)
        {
            var inventory_list = inventory[type];
            int max_items      = 2000;
            InventoryTypeOptions options;

            if (typeOptions.TryGetValue(type, out options))
            {
                max_items = options.maxItems;
            }
            if (inventory_list.Count() > max_items)
            {
                inventory_list.Remove(inventory_list.Keys.First());
            }
        }
Пример #7
0
        public PacketBRequestBuyItem(byte[] request)
        {
            using (MemoryStream Stream = new MemoryStream(request))
            {
                using (BinaryReader Reader = new BinaryReader(Stream))
                {
                    int ProtoNameLength = Reader.ReadInt32();

                    ProtoName = Encoding.Unicode.GetString(Reader.ReadBytes(ProtoNameLength));

                    InventoryItemTypes Type = (InventoryItemTypes)Reader.ReadInt32();
                    int ItemLength          = Reader.ReadInt32();

                    Item = Encoding.Unicode.GetString(Reader.ReadBytes(ItemLength));
                }
            }
        }
Пример #8
0
 virtual public bool setProcessedFlag(InventoryItemTypes type, byte[] hash, bool processed)
 {
     lock (inventory)
     {
         if (!inventory[type].ContainsKey(hash))
         {
             if (processed)
             {
                 var inventory_list = inventory[type];
                 inventory_list.Add(hash, new PendingInventoryItem(new InventoryItem(type, hash))
                 {
                     processed = processed
                 });
                 truncateInventory(type);
             }
         }
         else
         {
             inventory[type][hash].processed = processed;
             return(true);
         }
     }
     return(false);
 }
 public void Post([FromBody] InventoryItemTypes value)
 {
     _context.InventoryItemTypes.Add(value);
     _context.SaveChanges();
 }
Пример #10
0
 public InventoryItem(InventoryItemTypes type, byte[] hash)
 {
     this.type = type;
     this.hash = hash;
 }
Пример #11
0
        public bool processInventoryItem(InventoryItemTypes type, byte[] hash)
        {
            var pii = get(type, hash);

            return(processInventoryItem(pii));
        }