Ejemplo n.º 1
0
        public SingleTradelist AddSingleContainer(uint key)
        {
            SingleTradelist tradelist = new SingleTradelist();

            dict.Add(key, tradelist);
            return(tradelist);
        }
Ejemplo n.º 2
0
        public static TradelistContainer FromFile(string filename)
        {
            TradelistContainer _container  = new TradelistContainer();
            Tradelist          currentlist = null;

            if (File.Exists(filename))
            {
                using (TraderReader reader = TraderReader.Open(filename))
                    while (reader.Read())
                    {
                        _container.TradeMenu = reader.Menu;
                        switch (reader[reader.Trade].node)
                        {
                        case TraderReader.NodeTypeSpeciafier.Grouped:
                            goto AddGroupList;

                        case TraderReader.NodeTypeSpeciafier.Single:
                            goto AddSinglelist;
                        }
                        return(null);

AddGroupList:
                        GroupedTradelist gtrade = GetSafeGroup(_container, reader.Trade);
                        currentlist             = GetSafeList(gtrade, reader.Group - 1);
                        goto AddItemCount;
AddSinglelist:
                        SingleTradelist strade = GetSafeSingle(_container, reader.Trade);
                        currentlist            = strade.list;
                        goto AddItemCount;
AddItemCount:
                        switch (reader.Type)
                        {
                        case TraderReader.NodeType.Production:
                            currentlist.AddProduct(reader.ItemId, reader.ItemCount);
                            break;

                        case TraderReader.NodeType.Supplement:
                            currentlist.AddSupplement(reader.ItemId, reader.ItemCount);
                            break;
                        }
                    }
            }

            return(_container);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Helper funtion
        /// </summary>
        private static SingleTradelist GetSafeSingle(TradelistContainer _container, uint TradeId)
        {
            BaseTradelist blist = null;

            _container.dict.TryGetValue(TradeId, out blist);
            SingleTradelist slist = blist as SingleTradelist;

            if (slist != null)
            {
                return(slist);
            }
            else
            {
                slist = new SingleTradelist();
                _container.dict[TradeId] = slist;
                return(slist);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Helper funtion
 /// </summary>
 private static Tradelist GetSafeList(SingleTradelist l)
 {
     return(l.list);
 }
Ejemplo n.º 5
0
 public SingleTradelist AddSingleContainer(uint key)
 {
     SingleTradelist tradelist = new SingleTradelist();
     dict.Add(key, tradelist);
     return tradelist;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Helper funtion
 /// </summary>
 private static SingleTradelist GetSafeSingle(TradelistContainer _container, uint TradeId)
 {
     BaseTradelist blist = null;
     _container.dict.TryGetValue(TradeId, out blist);
     SingleTradelist slist = blist as SingleTradelist;
     if (slist != null)
     {
         return slist;
     }
     else
     {
         slist = new SingleTradelist();
         _container.dict[TradeId] = slist;
         return slist;
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Helper funtion
 /// </summary>
 private static Tradelist GetSafeList(SingleTradelist l)
 {
     return l.list;
 }