本文整理汇总了C#中MySql.Data.MySqlClient.MySqlPacket类的典型用法代码示例。如果您正苦于以下问题:C# MySqlPacket类的具体用法?C# MySqlPacket怎么用?C# MySqlPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySqlPacket类属于MySql.Data.MySqlClient命名空间,在下文中一共展示了MySqlPacket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MySqlException
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
{
if (!(val is TimeSpan))
throw new MySqlException("Only TimeSpan objects can be serialized by MySqlTimeSpan");
TimeSpan ts = (TimeSpan)val;
bool negative = ts.TotalMilliseconds < 0;
ts = ts.Duration();
if (binary)
{
packet.WriteByte(8);
packet.WriteByte((byte)(negative ? 1 : 0));
packet.WriteInteger(ts.Days, 4);
packet.WriteByte((byte)ts.Hours);
packet.WriteByte((byte)ts.Minutes);
packet.WriteByte((byte)ts.Seconds);
}
else
{
String s = String.Format("'{0}{1} {2:00}:{3:00}:{4:00}.{5}'",
negative ? "-" : "", ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
packet.WriteStringNoNull(s);
}
}
开发者ID:seeseekey,项目名称:CSCL,代码行数:26,代码来源:MySqlTime.cs
示例2:
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
{
var v = (val is double) ? (double)val : Convert.ToDouble(val);
if (binary)
packet.Write(BitConverter.GetBytes(v));
else
packet.WriteStringNoNull(v.ToString("R", CultureInfo.InvariantCulture));
}
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:8,代码来源:MySqlDouble.cs
示例3:
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
{
ulong v = (val is ulong) ? (ulong)val : Convert.ToUInt64(val);
if (binary)
packet.WriteInteger((long)v, 8);
else
packet.WriteStringNoNull(v.ToString());
}
开发者ID:Jankos132,项目名称:Server-Source,代码行数:8,代码来源:MySqlUInt64.cs
示例4:
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
{
int v = (val is Int32) ? (int)val : Convert.ToInt32(val);
if (binary)
packet.WriteInteger((long)v, 2);
else
packet.WriteStringNoNull(v.ToString());
}
开发者ID:Jankos132,项目名称:Server-Source,代码行数:8,代码来源:MySqlInt16.cs
示例5:
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
{
var v = (val is Int64) ? (Int64)val : Convert.ToInt64(val);
if (binary)
packet.WriteInteger(v, 8);
else
packet.WriteStringNoNull(v.ToString());
}
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:8,代码来源:MySqlInt64.cs
示例6: WriteValue
public void WriteValue(MySqlPacket packet, bool binary, object value, int length)
{
ulong v = (value is UInt64) ? (UInt64)value : Convert.ToUInt64(value);
if (binary)
packet.WriteInteger((long)v, 8);
else
packet.WriteStringNoNull(v.ToString());
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:MySqlBit.cs
示例7:
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
{
byte v = (val is byte) ? (byte)val : Convert.ToByte(val);
if (binary)
packet.WriteByte(v);
else
packet.WriteStringNoNull(v.ToString());
}
开发者ID:seeseekey,项目名称:CSCL,代码行数:8,代码来源:MySqlUByte.cs
示例8: ExecuteStatement
public override void ExecuteStatement(MySqlPacket packetToExecute)
{
base.ExecuteStatement(packetToExecute);
int pos = packetToExecute.Position;
packetToExecute.Position = 1;
int statementId = packetToExecute.ReadInteger(4);
packetToExecute.Position = pos;
MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementExecuted,
Resources.TraceStatementExecuted, driverId, statementId, ThreadID);
}
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:11,代码来源:TracingDriver.cs
示例9: MySqlStream
public MySqlStream(Encoding encoding)
{
// we have no idea what the real value is so we start off with the max value
// The real value will be set in NativeDriver.Configure()
maxPacketSize = ulong.MaxValue;
// we default maxBlockSize to MaxValue since we will get the 'real' value in
// the authentication handshake and we know that value will not exceed
// true maxBlockSize prior to that.
maxBlockSize = Int32.MaxValue;
packet = new MySqlPacket(encoding);
}
开发者ID:Arksutw,项目名称:mysql-dnxcore50,代码行数:13,代码来源:MySqlStream.cs
示例10:
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
{
string v = val.ToString();
if (length > 0)
{
length = Math.Min(length, v.Length);
v = v.Substring(0, length);
}
if (binary)
packet.WriteLenString(v);
else
packet.WriteStringNoNull("'" + MySqlHelper.EscapeString(v) + "'");
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:14,代码来源:MySqlString.cs
示例11: SendQuery
public override void SendQuery(MySqlPacket p)
{
rowSizeInBytes = 0;
string cmdText = Encoding.GetString(p.Buffer, 5, p.Length - 5);
string normalized_query = null;
if (cmdText.Length > 300)
{
QueryNormalizer normalizer = new QueryNormalizer();
normalized_query = normalizer.Normalize(cmdText);
cmdText = cmdText.Substring(0, 300);
}
base.SendQuery(p);
MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryOpened,
Resources.TraceQueryOpened, driverId, ThreadID, cmdText);
if (normalized_query != null)
MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryNormalized,
Resources.TraceQueryNormalized, driverId, ThreadID, normalized_query);
}
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:21,代码来源:TracingDriver.cs
示例12: MySqlBinary
IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal)
{
MySqlBinary b;
if (nullVal)
b = new MySqlBinary(type, true);
else
{
if (length == -1)
length = (long)packet.ReadFieldLength();
byte[] newBuff = new byte[length];
packet.Read(newBuff, 0, (int)length);
b = new MySqlBinary(type, newBuff);
}
return b;
}
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:16,代码来源:MySqlBinary.cs
示例13: MySqlByte
IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal)
{
if (nullVal)
return new MySqlByte(true);
if (length == -1)
return new MySqlByte((sbyte)packet.ReadByte());
else
{
string s = packet.ReadString(length);
MySqlByte b = new MySqlByte(SByte.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture));
b.TreatAsBoolean = TreatAsBoolean;
return b;
}
}
开发者ID:BGCX261,项目名称:zp-mysql-data-svn-to-git,代码行数:15,代码来源:MySqlByte.cs
示例14: SendPacket
public void SendPacket(MySqlPacket packet)
{
byte[] buffer = packet.Buffer;
int length = packet.Position-4;
if ((ulong)length > maxPacketSize)
throw new MySqlException(Resources.QueryTooLarge, (int)MySqlErrorCode.PacketTooLarge);
int offset = 0;
while (length > 0)
{
int lenToSend = length > maxBlockSize ? maxBlockSize : length;
buffer[offset] = (byte)(lenToSend & 0xff);
buffer[offset+1] = (byte)((lenToSend >> 8) & 0xff);
buffer[offset+2] = (byte)((lenToSend >> 16) & 0xff);
buffer[offset+3] = sequenceByte++;
outStream.Write(buffer, offset, lenToSend + 4);
outStream.Flush();
length -= lenToSend;
offset += lenToSend;
}
}
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:23,代码来源:MySqlStream.cs
示例15: Prepare
public virtual void Prepare()
{
// strip out names from parameter markers
string text;
List<string> parameter_names = PrepareCommandText(out text);
// ask our connection to send the prepare command
MySqlField[] paramList = null;
statementId = Driver.PrepareStatement(text, ref paramList);
// now we need to assign our field names since we stripped them out
// for the prepare
for (int i = 0; i < parameter_names.Count; i++)
{
//paramList[i].ColumnName = (string) parameter_names[i];
string parameterName = (string)parameter_names[i];
MySqlParameter p = Parameters.GetParameterFlexible(parameterName, false);
if (p == null)
throw new InvalidOperationException(
String.Format(Resources.ParameterNotFoundDuringPrepare, parameterName));
p.Encoding = paramList[i].Encoding;
parametersToSend.Add(p);
}
// now prepare our null map
int numNullBytes = 0;
if (paramList != null && paramList.Length > 0)
{
nullMap = new BitArray(paramList.Length);
numNullBytes = (nullMap.Count + 7) / 8;
}
packet = new MySqlPacket(Driver.Encoding);
// write out some values that do not change run to run
packet.WriteByte(0);
packet.WriteInteger(statementId, 4);
packet.WriteByte((byte)0); // flags; always 0 for 4.1
packet.WriteInteger(1, 4); // interation count; 1 for 4.1
nullMapPosition = packet.Position;
packet.Position += numNullBytes; // leave room for our null map
packet.WriteByte(1); // rebound flag
// write out the parameter types
foreach (MySqlParameter p in parametersToSend)
packet.WriteInteger(p.GetPSType(), 2);
dataPosition = packet.Position;
}
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:47,代码来源:PreparableStatement.cs
示例16:
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object v, int length)
{
uint val = (v is uint) ? (uint)v : Convert.ToUInt32(v);
if (binary)
packet.WriteInteger((long)val, is24Bit ? 3 : 4);
else
packet.WriteStringNoNull(val.ToString());
}
开发者ID:zibler,项目名称:zibler,代码行数:8,代码来源:MySqlUInt32.cs
示例17:
void IMySqlValue.SkipValue(MySqlPacket packet)
{
int len = packet.ReadByte();
packet.Position += len;
}
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:5,代码来源:MySqlDateTime.cs
示例18: if
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object value, int length)
{
MySqlDateTime dtValue;
var valueAsString = value as string;
if (value is DateTime)
dtValue = new MySqlDateTime(type, (DateTime)value);
else if (valueAsString != null)
dtValue = Parse(valueAsString);
else if (value is MySqlDateTime)
dtValue = (MySqlDateTime)value;
else
throw new MySqlException("Unable to serialize date/time value.");
if (!binary)
{
SerializeText(packet, dtValue);
return;
}
if (dtValue.Millisecond > 0)
packet.WriteByte(11);
else
packet.WriteByte(7);
packet.WriteInteger(dtValue.Year, 2);
packet.WriteByte((byte)dtValue.Month);
packet.WriteByte((byte)dtValue.Day);
if (type == MySqlDbType.Date)
{
packet.WriteByte(0);
packet.WriteByte(0);
packet.WriteByte(0);
}
else
{
packet.WriteByte((byte)dtValue.Hour);
packet.WriteByte((byte)dtValue.Minute);
packet.WriteByte((byte)dtValue.Second);
}
if (dtValue.Millisecond > 0)
{
long val = dtValue.Millisecond < 1000 ? dtValue.Millisecond * 1000 : dtValue.Millisecond;
for (var x = 0; x < 4; x++)
{
packet.WriteByte((byte)(val & 0xff));
val >>= 8;
}
}
}
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:52,代码来源:MySqlDateTime.cs
示例19: EscapeByteArray
private static void EscapeByteArray(byte[] bytes, int length, MySqlPacket packet)
{
for (int x = 0; x < length; x++)
{
byte b = bytes[x];
if (b == '\0')
{
packet.WriteByte((byte)'\\');
packet.WriteByte((byte)'0');
}
else if (b == '\\' || b == '\'' || b == '\"')
{
packet.WriteByte((byte)'\\');
packet.WriteByte(b);
}
else
packet.WriteByte(b);
}
}
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:20,代码来源:MySqlBinary.cs
示例20:
void IMySqlValue.SkipValue(MySqlPacket packet)
{
int len = packet.ReadFieldLength();
packet.Position += len;
}
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:5,代码来源:MySqlBinary.cs
注:本文中的MySql.Data.MySqlClient.MySqlPacket类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论