コード例 #1
0
ファイル: Row.cs プロジェクト: txdv/LibuvSharp.MySql
		internal Row(Fields fields, string[] values)
		{
			Fields = fields;
			Values = values;
			
			Length = Fields.FieldPackets.Length;
		}
コード例 #2
0
ファイル: MySqlClient.cs プロジェクト: txdv/LibuvSharp.MySql
		IEnumerable<bool> ProcessRequest(byte packetNumber, byte[] packet)
		{
			var queryCommand = commands.Peek().Callback;

			packetReader.NewPacket(packet);

			var type = ResponsePacket.GetType(packet);

			if (type != ResponsePacketType.Other) {
				var responsePacket = ResponsePacket.Parse(packetReader);

				queryCommand.FireResponse(responsePacket);
				FireNextCommand();
				yield return true;
				yield break;
			}

			long length = packetReader.ReadLength();

			byte[] data;
			byte num;

			FieldPacket[] fields = new FieldPacket[length];

			for (int i = 0; i < length; i++) {
				while (!ReadPacket(out num, out data)) {
					yield return false;
				}

				packetReader.NewPacket(data);
				var field = FieldPacket.Parse(packetReader);
				fields[i] = field;
			}

			var f = new Fields(fields);

			while (!ReadPacket(out num, out data)) {
				yield return false;
			}

			queryCommand.FireFields(f.FieldPackets);

			packetReader.NewPacket(data);
			// TODO: check if the packet is in place
			EOFPacket.Parse(packetReader);


			while (true) {
				while (!ReadPacket(out num, out data)) {
					yield return false;
				}

				if (ResponsePacket.GetType(data) == ResponsePacketType.EOF) {
					queryCommand.FireEnd();
					FireNextCommand();
					yield return true;
					yield break;
				}

				packetReader.NewPacket(data);
				string[] values = new string[length];
				for (int i = 0; i < length; i++) {
					values[i] = packetReader.ReadLengthString();
				}

				queryCommand.FireRow(new Row(f, values));
			}
		}