Exemplo n.º 1
0
		public override void AddMember(SNode node)
		{
			if (!(Members.Length < GivenLength))
				throw new SystemException();

			Members.Add(node);
		}
		public MarketOrderParser(SNode stream)
		{
			List = new MarketList();
			Stream = new SNodeContainer();
			Stream.Add(stream);
			Valid = false;
		}
Exemplo n.º 3
0
		static string market(SNode start)
		{
			StringBuilder sb = new StringBuilder();
			MarketOrderParser mp = new MarketOrderParser(start);
			try
			{
				mp.Parse();
			}
			catch (ParseException e)
			{
				sb.Append("Not a valid orders file due to " + e.Message);
				return null;
			}
			MarketList list = mp.List;

			DateTime t = list.TimeStamp;

			string timeString = t.ToString("yyyy-MM-dd HH:mm:ss");
			sb.Append("MarketList for region " + list.Region + " and type " + list.Type + 
								" at time " + timeString + "\n");

			sb.Append("price,volRemaining,typeID,range,orderID,volEntered,minVolume,bid,issued,duration,stationID,regionID,solarSystemID,jumps,\n");

			List<MarketOrder> buy = list.BuyOrders;
			List<MarketOrder> sell = list.SellOrders;
			foreach (MarketOrder o in sell)
			{
				sb.Append(o.ToCsv() + "\n");
			}
			foreach (MarketOrder o in buy)
			{
				sb.Append(o.ToCsv() + "\n");
			}
			return sb.ToString();
		}
Exemplo n.º 4
0
		private void ParseNewHistory(SNode baseNode)
		{
			SNode obj = baseNode.Members[1].Members[6];
			if (obj == null)
				return;
			Parse(obj);
			Valid = true;
		}
Exemplo n.º 5
0
        private void ParseNewHistory(SNode baseNode)
        {
            SNode obj = baseNode.Members[1].Members[6];

            if (obj == null)
            {
                return;
            }
            Parse(obj);
            Valid = true;
        }
Exemplo n.º 6
0
        protected void Parse(SNode stream, int limit)
        {
            while (!Reader.AtEnd && limit != 0)
            {
                SNode thisobj = ParseOne();
                if (thisobj != null)
                {
                    stream.AddMember(thisobj);
                }

                limit--;
            }
        }
Exemplo n.º 7
0
        private void InitWithFile(string fileName)
        {
            CacheFileReader cfReader = new CacheFileReader(fileName);

            CacheFileParser parser = new CacheFileParser(cfReader);

            parser.Parse();
            SNode sNode = parser.Streams[0];

            Stream = sNode.Members;
            Parse();
            Stream = null;
            Valid  = true;
        }
Exemplo n.º 8
0
		public static string DumpNode(SNode node, int offset)
		{
			if (node.Members.Length == 0)
				return "";

			StringBuilder sb = new StringBuilder();
			sb.Append("(\n".PadLeft(2 * offset));
			foreach (SNode n in node.Members)
			{
				sb.Append(n.ToString().PadLeft((2 * offset) + n.ToString().Length));
				sb.Append(String.Format("[{0:00}]\n", n.__id__));
				if (n.Members.Length > 0)
					sb.Append(DumpNode(n, offset + 1));
				__nodeConsumed__[n.__id__] = true;
			}
			sb.Append(")\n".PadLeft(2 * offset));

			return sb.ToString();
		}
Exemplo n.º 9
0
 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]);
             }
         }
     }
 }
Exemplo n.º 10
0
		static string marketHistory(SNode start)
		{
			StringBuilder sb = new StringBuilder();
			MarketHistoryParser mp = new MarketHistoryParser(start);
			try
			{
				mp.Parse();
			}
			catch (ParseException e)
			{
				sb.Append("Not a valid history file due to " + e.Message);
				return null;
			}

			foreach (MarketHistory history in mp.List)
			{
				sb.Append(history.ToCsv() + "\n");
			}

			return sb.ToString();
		}
Exemplo n.º 11
0
        protected void ShareAdd(SNode obj)
        {
            if (ShareMap == null || ShareObj == null)
            {
                throw new ParseException("Uninitialized share");
            }
            if (ShareCursor >= ShareCount)
            {
                throw new ParseException("cursor out of range");
            }
            int shareid = ShareMap[ShareCursor];

            if (shareid > ShareCount)
            {
                throw new ParseException("shareid out of range");
            }


            ShareObj[shareid] = obj.Clone();

            ShareCursor++;
        }
Exemplo n.º 12
0
        public static string DumpNode(SNode node, int offset)
        {
            if (node.Members.Length == 0)
            {
                return("");
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("(\n".PadLeft(2 * offset));
            foreach (SNode n in node.Members)
            {
                sb.Append(n.ToString().PadLeft((2 * offset) + n.ToString().Length));
                sb.Append(String.Format("[{0:00}]\n", n.__id__));
                if (n.Members.Length > 0)
                {
                    sb.Append(DumpNode(n, offset + 1));
                }
                __nodeConsumed__[n.__id__] = true;
            }
            sb.Append(")\n".PadLeft(2 * offset));

            return(sb.ToString());
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
		protected void ShareAdd(SNode obj)
		{
			if (ShareMap == null || ShareObj == null)
				throw new ParseException("Uninitialized share");
			if (ShareCursor >= ShareCount)
				throw new ParseException("cursor out of range");
			int shareid = ShareMap[ShareCursor];
			if (shareid > ShareCount)
				throw new ParseException("shareid out of range");

			
			ShareObj[shareid] = obj.Clone();

			ShareCursor++;
		}
Exemplo n.º 15
0
 public MarketHistoryParser(SNode stream)
 {
     List   = new List <MarketHistory>();
     Stream = stream;
     Valid  = false;
 }
Exemplo n.º 16
0
		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);
		}
Exemplo n.º 17
0
		protected int ShareInit()
		{
			int shares = Reader.ReadInt();
			if ((uint)shares >= 16384) // Some large number
				return 0;

			int shareSkip = 0;
			if (shares != 0)
			{
				ShareMap = new int[shares + 1];
				ShareObj = new SNode[shares + 1];

				shareSkip = 4 * shares;
				int oPosition = Reader.Position;
				int oLimit = Reader.Limit;
				Reader.Seek(shareSkip, SeekOrigin.End);
				for (int i = 0; i < shares; i++)
				{
					ShareMap[i] = Reader.ReadInt();
				}
				ShareMap[shares] = 0;

				Reader.Seek(oPosition, SeekOrigin.Begin);
				Reader.Limit = oLimit - shareSkip;
			}
			ShareCount = shares;
			return shares;
		}
Exemplo n.º 18
0
		public virtual void AddMember(SNode node)
		{
			Members.Add(node);
		}
Exemplo n.º 19
0
		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]);
				}
			}
		}
Exemplo n.º 20
0
        public void Parse()
        {
            if (Stream == null)
            {
                return;
            }

            /* Todo: fixed offsets = bad :) */
            /* Step 1: Determine if this is a market order file */
            if (Stream[0].Members.Length < 1)
            {
                throw new ParseException("Not a valid file");
            }

            SNode baseNode = Stream[0].Members[0];

            if (baseNode.Members.Length < 1)
            {
                throw new ParseException("Not a valid orders file");
            }
            if (baseNode.Members[0].Members.Length < 2)
            {
                throw new ParseException("Not a valid orders file");
            }

            SIdent id = baseNode.Members[0].Members[1] as SIdent;

            if (id == null)
            {
                throw new ParseException("Can't determine method name");
            }
            if (id.Value != "GetOrders")
            {
                throw new ParseException("Not a valid orders file");
            }

            /* Retrieve the region and type */
            SInt region = baseNode.Members[0].Members[2] as SInt;
            SInt type   = baseNode.Members[0].Members[3] as SInt;

            List.Region = region.Value;
            List.Type   = type.Value;

            /* Try to extract the in-file timestamp */
            SDict dict = baseNode.Members[1] as SDict;

            if (dict == null)
            {
                throw new ParseException("Can't read file timestamp");
            }

            // Grab the version entry of the version tuple
            SLong time = dict.GetByName("version").Members[0] as SLong;

            if (time == null)
            {
                throw new ParseException("Can't read file timestamp");
            }

            Console.WriteLine("TS: " + time.Value);
            List.TimeStamp = new DateTime(time.Value + 504911232000000000);

            SNode obj = baseNode.Members[1].Members[0];

            if (obj == null)
            {
                return;
            }
            Parse(obj);
            Valid = true;
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
 public virtual void AddMember(SNode node)
 {
     Members.Add(node);
 }
Exemplo n.º 23
0
		protected void Parse(SNode stream, int limit)
		{
			while (!Reader.AtEnd && limit != 0)
			{
				SNode thisobj = ParseOne();
				if (thisobj != null)
					stream.AddMember(thisobj);

				limit--;
			}
		}
Exemplo n.º 24
0
        protected SNode GetDBRow()
        {
            SNode nhead = ParseOne();
            // get header
            SObject head = nhead as SObject;

            if (head == null)
            {
                throw new ParseException("The DBRow header isn't present...");
            }

            if (head.Name != "blue.DBRowDescriptor")
            {
                throw new ParseException("Bad descriptor name");
            }

            STuple fields = head.Members[0].Members[1].Members[0] as STuple;

            int len = GetLength();

            byte[] olddata = Reader.ReadBytes(len);

            List <byte> newdata = new List <byte>();

            rle_unpack(olddata, newdata);
            SNode body = new SDBRow(17, newdata);

            CacheFileReader blob = new CacheFileReader(newdata.ToArray());

            SDict dict = new SDict(999999);             // TODO: need dynamic sized dict
            int   step = 1;

            while (step < 6)
            {
                foreach (SNode field in fields.Members)
                {
                    SNode fieldName    = field.Members[0];
                    SInt  fieldType    = field.Members[1] as SInt;
                    int   fieldTypeInt = fieldType.Value;

                    byte  boolcount = 0;
                    byte  boolbuf   = 0;
                    SNode obj       = null;
                    switch (fieldTypeInt)
                    {
                    case 2:                             // 16bit int
                        if (step == 3)
                        {
                            obj = new SInt(blob.ReadShort());
                        }
                        break;

                    case 3:                             // 32bit int
                        if (step == 2)
                        {
                            obj = new SInt(blob.ReadInt());
                        }
                        break;

                    case 4:
                        obj = new SReal(blob.ReadFloat());
                        break;

                    case 5:                             // double
                        if (step == 1)
                        {
                            obj = new SReal(blob.ReadDouble());
                        }
                        break;

                    case 6:                             // currency
                        if (step == 1)
                        {
                            obj = new SLong(blob.ReadLong());
                        }
                        break;

                    case 11:                             // boolean
                        if (step == 5)
                        {
                            if (boolcount == 0)
                            {
                                boolbuf   = blob.ReadByte();
                                boolcount = 0x1;
                            }
                            if (boolbuf != 0 && boolcount != 0)
                            {
                                obj = new SInt(1);
                            }
                            else
                            {
                                obj = new SInt(0);
                            }
                            boolcount <<= 1;
                        }
                        break;

                    case 16:
                        obj = new SInt(blob.ReadByte());
                        break;

                    case 17:
                        goto case 16;

                    case 18:                             // 16bit int
                        goto case 2;

                    case 19:                             // 32bit int
                        goto case 3;

                    case 20:                             // 64bit int
                        goto case 6;

                    case 21:                             // 64bit int
                        goto case 6;

                    case 64:                             // timestamp
                        goto case 6;

                    case 128:                             // string types
                    case 129:
                    case 130:
                        obj = new SString("I can't parse strings yet - be patient");
                        break;

                    default:
                        throw new ParseException("Unhandled ADO type " + fieldTypeInt);
                    }

                    if (obj != null)
                    {
                        dict.AddMember(obj);
                        dict.AddMember(fieldName.Clone());
                    }
                }

                step++;
            }

            SNode fakerow = new STuple(3);

            fakerow.AddMember(head);
            fakerow.AddMember(body);
            fakerow.AddMember(dict);
            return(fakerow);
        }
Exemplo n.º 25
0
        protected SNode ParseOne()
        {
            EStreamCode check;
            byte        isshared  = 0;
            SNode       thisobj   = null;
            SDBRow      lastDbRow = null;

            try
            {
                byte type = Reader.ReadByte();
                check    = (EStreamCode)(type & 0x3f);
                isshared = (byte)(type & 0x40);
            }
            catch (EndOfFileException)
            {
                return(null);
            }

            #region EStreamCode Switch
            switch (check)
            {
            case EStreamCode.EStreamStart:
                break;

            case EStreamCode.ENone:
                thisobj = new SNone();
                break;

            case EStreamCode.EString:
                thisobj = new SString(Reader.ReadString(Reader.ReadByte()));
                break;

            case EStreamCode.ELong:
                thisobj = new SLong(Reader.ReadLong());
                break;

            case EStreamCode.EInteger:
                thisobj = new SInt(Reader.ReadInt());
                break;

            case EStreamCode.EShort:
                thisobj = new SInt(Reader.ReadShort());
                break;

            case EStreamCode.EByte:
                thisobj = new SInt(Reader.ReadByte());
                break;

            case EStreamCode.ENeg1Integer:
                thisobj = new SInt(-1);
                break;

            case EStreamCode.E0Integer:
                thisobj = new SInt(0);
                break;

            case EStreamCode.E1Integer:
                thisobj = new SInt(1);
                break;

            case EStreamCode.EReal:
                thisobj = new SReal(Reader.ReadDouble());
                break;

            case EStreamCode.E0Real:
                thisobj = new SReal(0);
                break;

            case EStreamCode.E0String:
                thisobj = new SString(null);
                break;

            case EStreamCode.EString3:
                thisobj = new SString(Reader.ReadString(1));
                break;

            case EStreamCode.EString4:
                goto case EStreamCode.EString;

            case EStreamCode.EMarker:
                thisobj = new SMarker((byte)GetLength());
                break;

            case EStreamCode.EUnicodeString:
                goto case EStreamCode.EString;

            case EStreamCode.EIdent:
                thisobj = new SIdent(Reader.ReadString(GetLength()));
                break;

            case EStreamCode.ETuple:
            {
                int length = GetLength();
                thisobj = new STuple((uint)length);
                Parse(thisobj, length);
                break;
            }

            case EStreamCode.ETuple2:
                goto case EStreamCode.ETuple;

            case EStreamCode.EDict:
            {
                int   len  = (GetLength() * 2);
                SDict dict = new SDict((uint)len);
                thisobj = dict;
                Parse(dict, len);
                break;
            }

            case EStreamCode.EObject:
                thisobj = new SObject();
                Parse(thisobj, 2);
                break;

            case EStreamCode.ESharedObj:
                thisobj = ShareGet(GetLength());
                break;

            case EStreamCode.EChecksum:
                thisobj = new SString("checksum");
                Reader.ReadInt();
                break;

            case EStreamCode.EBoolTrue:
                thisobj = new SInt(1);
                break;

            case EStreamCode.EBoolFalse:
                thisobj = new SInt(0);
                break;

            case EStreamCode.EObject22:
            {
                SObject obj = new SObject();
                thisobj = obj;
                Parse(thisobj, 1);

                string oclass = obj.Name;
                if (oclass == "dbutil.RowList")
                {
                    SNode row;
                    while ((row = ParseOne()) != null)
                    {
                        obj.AddMember(row);
                    }
                }
                break;
            }

            case EStreamCode.EObject23:
                goto case EStreamCode.EObject22;

            case EStreamCode.E0Tuple:
                thisobj = new STuple(0);
                break;

            case EStreamCode.E1Tuple:
                thisobj = new STuple(1);
                Parse(thisobj, 1);
                break;

            case EStreamCode.E0Tuple2:
                goto case EStreamCode.E0Tuple;

            case EStreamCode.E1Tuple2:
                goto case EStreamCode.E1Tuple;

            case EStreamCode.EEmptyString:
                thisobj = new SString(string.Empty);
                break;

            case EStreamCode.EUnicodeString2:
                /* Single unicode character */
                thisobj = new SString(Reader.ReadString(2));
                break;

            case EStreamCode.ECompressedRow:
                thisobj = GetDBRow();
                break;

            case EStreamCode.ESubstream:
            {
                int             len       = GetLength();
                CacheFileReader readerSub = new CacheFileReader(Reader, len);
                SSubStream      ss        = new SSubStream(len);
                thisobj = ss;
                CacheFileParser sp = new CacheFileParser(readerSub);
                sp.Parse();
                for (int i = 0; i < sp.Streams.Count; i++)
                {
                    ss.AddMember(sp.Streams[i].Clone());
                }

                Reader.Seek(readerSub.Position, SeekOrigin.Begin);
                break;
            }

            case EStreamCode.E2Tuple:
                thisobj = new STuple(2);
                Parse(thisobj, 2);
                break;

            case EStreamCode.EString2:
                goto case EStreamCode.EString;

            case EStreamCode.ESizedInt:
                switch (Reader.ReadByte())
                {
                case 8:
                    thisobj = new SLong(Reader.ReadLong());
                    break;

                case 4:
                    thisobj = new SInt(Reader.ReadInt());
                    break;

                case 3:
                    // The following seems more correct than the forumla used.
                    // int value = (Reader.Char() << 16) + (Reader.ReadByte());
                    thisobj = new SInt((Reader.ReadByte()) + (Reader.ReadByte() << 16));
                    break;

                case 2:
                    thisobj = new SInt(Reader.ReadShort());
                    break;
                }
                break;

            case (EStreamCode)0x2d:
                if (Reader.ReadByte() != (byte)0x2d)
                {
                    throw new ParseException("Didn't encounter a double 0x2d where one was expected at " + (Reader.Position - 2));
                }
                else if (lastDbRow != null)
                {
                    lastDbRow.IsLast = true;
                }
                return(null);

            case 0:
                break;

            default:
                throw new ParseException("Can't identify type " + String.Format("{0:x2}", (int)check) +
                                         " at position " + String.Format("{0:x2}", Reader.Position) + " limit " + Reader.Length);
            }
            #endregion

            if (thisobj == null)
            {
                throw new ParseException("no thisobj in parseone");
            }

            if (isshared != 0)
            {
                if (thisobj == null)
                {
                    throw new ParseException("shared flag but no obj");
                }
                ShareAdd(thisobj);
            }

            return(thisobj);
        }
Exemplo n.º 26
0
		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);
		}
Exemplo n.º 27
0
		public SNode(SNode source)
		{
			Members = new SNodeContainer(source.Members);
			Type = source.Type;
		}
Exemplo n.º 28
0
		public MarketHistoryParser(SNode stream)
		{
			List = new List<MarketHistory>();
			Stream = stream;
			Valid = false;
		}
Exemplo n.º 29
0
 public SNode(SNode source)
 {
     Members = new SNodeContainer(source.Members);
     Type    = source.Type;
 }
Exemplo n.º 30
0
		public void Parse()
		{
			try
			{
				while (!Reader.AtEnd)
				{
					EStreamCode check = (EStreamCode)Reader.ReadByte();
					SNode stream = new SNode(EStreamCode.EStreamStart);
					
					if (check != EStreamCode.EStreamStart)
						continue;

					Streams.Add(stream);
					ShareInit();
					Parse(stream, 1); // -1 = not sure how long this will be

					ShareSkip();
				}
			}
			catch (EndOfFileException)
			{
				// Ignore the exception, parser has run amok!
			}
		}