本文整理汇总了C#中MySql.Data.MySqlClient.MySqlStream.WriteStringNoNull方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlStream.WriteStringNoNull方法的具体用法?C# MySqlStream.WriteStringNoNull怎么用?C# MySqlStream.WriteStringNoNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlStream
的用法示例。
在下文中一共展示了MySqlStream.WriteStringNoNull方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteValue
public void WriteValue(MySqlStream stream, bool binary, object value, int length)
{
ulong v = Convert.ToUInt64(value);
if (binary)
stream.Write(BitConverter.GetBytes(v));
else
stream.WriteStringNoNull(v.ToString());
}
示例2:
void IMySqlValue.WriteValue(MySqlStream stream, bool binary, object val, int length)
{
int v = Convert.ToInt32(val);
if (binary)
stream.Write(BitConverter.GetBytes(v));
else
stream.WriteStringNoNull(v.ToString());
}
示例3:
void IMySqlValue.WriteValue(MySqlStream stream, bool binary, object val, int length)
{
Single v = Convert.ToSingle(val);
if (binary)
stream.Write(BitConverter.GetBytes(v));
else
stream.WriteStringNoNull(v.ToString("R",
CultureInfo.InvariantCulture));
}
示例4: Serialize
internal void Serialize(MySqlStream stream, bool binary)
{
IMySqlValue v = MySqlField.GetIMySqlValue(mySqlDbType);
if (!binary && (paramValue == null || paramValue == DBNull.Value))
stream.WriteStringNoNull("NULL");
else
v.WriteValue(stream, binary, paramValue, size);
}
示例5: MySqlException
void IMySqlValue.WriteValue(MySqlStream stream, 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;
if (binary)
{
stream.WriteByte(8);
stream.WriteByte((byte)(ts.TotalSeconds < 0 ? 1 : 0));
stream.WriteInteger(ts.Days, 4);
stream.WriteByte((byte)ts.Hours);
stream.WriteByte((byte)ts.Minutes);
stream.WriteByte((byte)ts.Seconds);
}
else
{
stream.WriteStringNoNull(String.Format("'{0} {1:00}:{2:00}:{3:00}.{4}'",
ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds));
}
}
示例6: EscapeString
void IMySqlValue.WriteValue(MySqlStream stream, 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)
stream.WriteLenString(v);
else
stream.WriteStringNoNull("'" + EscapeString(v) + "'");
}
示例7:
void IMySqlValue.WriteValue(MySqlStream stream, bool binary, object val, int length)
{
sbyte v = ((IConvertible)val).ToSByte(null);
if (binary)
stream.WriteByte((byte)v);
else
stream.WriteStringNoNull(v.ToString());
}
示例8:
void IMySqlValue.WriteValue(MySqlStream stream, bool binary, object val, int length)
{
decimal v = Convert.ToDecimal(val);
string valStr = v.ToString(CultureInfo.InvariantCulture);
if (binary)
stream.WriteLenString(valStr);
else
stream.WriteStringNoNull(valStr);
}
示例9: SerializeText
private void SerializeText(MySqlStream stream, MySqlDateTime value)
{
string val = String.Empty;
if (type == MySqlDbType.Timestamp && !stream.Version.isAtLeast(4, 1, 0))
val = String.Format("{0:0000}{1:00}{2:00}{3:00}{4:00}{5:00}",
value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second);
else
{
val = String.Format("{0:0000}-{1:00}-{2:00}",
value.Year, value.Month, value.Day);
if (type != MySqlDbType.Date)
val = String.Format("{0} {1:00}:{2:00}:{3:00}", val,
value.Hour, value.Minute, value.Second);
}
stream.WriteStringNoNull("'" + val + "'");
}
示例10: if
void IMySqlValue.WriteValue(MySqlStream stream, bool binary, object val, int length)
{
byte[] buffToWrite = null;
if (val is System.Byte[])
buffToWrite = (byte[])val;
else if (val is Char[])
buffToWrite = stream.Encoding.GetBytes(val as char[]);
else
{
string s = val.ToString();
if (length == 0)
length = s.Length;
else
s = s.Substring(0, length);
buffToWrite = stream.Encoding.GetBytes(s);
}
// we assume zero length means write all of the value
if (length == 0)
length = buffToWrite.Length;
if (buffToWrite == null)
throw new MySqlException("Only byte arrays and strings can be serialized by MySqlBinary");
if (binary)
{
stream.WriteLength(length);
stream.Write(buffToWrite, 0, length);
}
else
{
if (stream.Version.isAtLeast(4, 1, 0))
stream.WriteStringNoNull("_binary ");
stream.WriteByte((byte)'\'');
EscapeByteArray(buffToWrite, length, stream);
stream.WriteByte((byte)'\'');
}
}