public MarketOrderParser(SNode stream)
 {
     List   = new MarketList();
     Stream = new SNodeContainer();
     Stream.Add(stream);
     Valid = false;
 }
Esempio n. 2
0
 public SNode(EStreamCode t)
 {
     __id__ = __count__++;
     __nodes__.Add(this);
     Members = new SNodeContainer();
     Type    = t;
 }
Esempio n. 3
0
 public SNodeContainer(SNodeContainer source, int start, int limit)
 {
     Data = new List <SNode>(limit - start);
     for (int i = start; i < limit; i++)
     {
         Data[i] = source[i];
     }
 }
 private void Parse(SNode node)
 {
     if (node.Members.Length > 0)
     {
         SNodeContainer members = node.Members;
         for (int i = 0; i < members.Length; i++)
         {
             SDBRow dbrow = members[i] as SDBRow;
             if (dbrow != null)
             {
                 ParseDbRow(members[++i]);
             }
             else
             {
                 Parse(members[i]);
             }
         }
     }
 }
Esempio n. 5
0
 public SNodeContainer(SNodeContainer source, int start) : this(source, start, source.Length)
 {
 }
Esempio n. 6
0
 public Iterator(SNodeContainer parent)
 {
     Data     = parent._Data;
     Position = -1;
 }
        private void ParseDbRow(SNode node)
        {
            MarketOrder order = new MarketOrder();

            SNodeContainer members = node.Members;

            for (int i = 0; i < members.Length; i++)
            {
                SNode value = members[i];
                i++;
                SMarker key   = members[i] as SMarker;
                SIdent  ident = members[i] as SIdent;

                int typeKey = -1;

                if (key != null)
                {
                    typeKey = key.ID;
                }
                else if (ident != null && ident.Value == "issueDate")
                {
                    typeKey = 131;
                }
                else
                {
                    Console.WriteLine("Can't parse - giving up");
                    break;
                }

                SInt  intV  = value as SInt;
                SLong longV = value as SLong;
                SReal realV = value as SReal;

                int    sintV  = 0;
                long   slongV = 0;
                double srealV = 0.0;

                if (intV != null)
                {
                    sintV = intV.Value;
                }
                else if (longV != null)
                {
                    slongV = longV.Value;
                }
                else if (realV != null)
                {
                    srealV = realV.Value;
                }

                switch (typeKey)
                {
                case 139:
                    order.Price = slongV;
                    break;

                case 161:
                    order.VolRemaining = srealV;
                    break;

                case 131:
                    order.Issued = slongV;
                    break;

                case 138:
                    order.OrderID = slongV;
                    break;

                case 160:
                    order.VolEntered = sintV;
                    break;

                case 137:
                    order.MinVolume = sintV;
                    break;

                case 155:
                    order.StationID = sintV;
                    break;

                case 141:
                    order.RegionID = sintV;
                    List.Region    = sintV;
                    break;

                case 150:
                    order.SolarSystemID = sintV;
                    break;

                case 41:
                    order.Jumps = sintV;
                    break;

                case 74:
                    order.Type = sintV;
                    List.Type  = sintV;
                    break;

                case 140:
                    order.Range = sintV;
                    break;

                case 126:
                    order.Duration = sintV;
                    break;

                case 116:
                    if (sintV != 0)
                    {
                        order.IsBid = true;
                    }
                    else
                    {
                        order.IsBid = false;
                    }
                    break;

                default:
                    Console.WriteLine("Unknown key ID:" + key.ID + " r: " + srealV + " l: " + slongV + " i: " + sintV);
                    break;
                }
            }

            List.AddOrder(order);
        }
Esempio n. 8
0
 public SNode(SNode source)
 {
     Members = new SNodeContainer(source.Members);
     Type    = source.Type;
 }
        private void ParseDbRow(SNode node)
        {
            MarketHistory history = new MarketHistory();

            history.Region = Region;
            history.Type   = Type;

            SNodeContainer members = node.Members;

            for (int i = 0; i < members.Length; i++)
            {
                SNode  value = members[i++];
                SIdent ident = members[i] as SIdent;

                SInt  intV  = value as SInt;
                SLong longV = value as SLong;

                int  sintV  = 0;
                long slongV = 0;

                if (intV != null)
                {
                    sintV = intV.Value;
                }
                else if (longV != null)
                {
                    slongV = longV.Value;
                }

                switch (ident.Value)
                {
                case "historyDate":
                    history.HistoryTicks = slongV;
                    break;

                case "lowPrice":
                    history.LowPrice = slongV;
                    break;

                case "highPrice":
                    history.HighPrice = slongV;
                    break;

                case "avgPrice":
                    history.AveragePrice = slongV;
                    break;

                case "volume":
                    history.Volume = slongV;
                    break;

                case "orders":
                    history.Orders = sintV;
                    break;

                default:
                    throw new ParseException("Can't parse " + ident);
                }
            }
            List.Add(history);
        }