コード例 #1
0
        public void RemoveItem(uint id)
        {
            ITwinItem listItem = GetItem(id);

            if (listItem != null)
            {
                Items.Remove(listItem);
            }
        }
コード例 #2
0
 public void Read(BinaryReader reader, int length)
 {
     if (length > 0)
     {
         Int64 baseOffset = reader.BaseStream.Position;
         magicNumber = reader.ReadUInt32();
         UInt32   itemsCount   = reader.ReadUInt32();
         UInt32   streamLength = reader.ReadUInt32();
         Record[] records      = new Record[itemsCount];
         for (int i = 0; i < itemsCount; ++i)
         {
             Record record = new Record();
             record.Read(reader, 12);
             records[i] = record;
         }
         Items.Clear();
         for (int i = 0; i < itemsCount; ++i)
         {
             ITwinItem item = null;
             if (idToClassDictionary.ContainsKey(records[i].ItemId))
             {
                 Type type = idToClassDictionary[records[i].ItemId];
                 item = (ITwinItem)Activator.CreateInstance(type);
             }
             else
             {
                 item = (ITwinItem)Activator.CreateInstance(defaultType);
             }
             reader.BaseStream.Position = records[i].Offset + baseOffset;
             item.Read(reader, (Int32)records[i].Size);
             item.SetID(records[i].ItemId);
             Items.Add(item);
         }
         extraData = reader.ReadBytes((Int32)(length - (reader.BaseStream.Position - baseOffset)));
     }
     else
     {
         skip = true;
     }
 }
コード例 #3
0
 public void AddItem(ITwinItem item)
 {
     Items.Add(item);
 }