当前位置: 首页>>代码示例>>C#>>正文


C# MySqlClient.MySqlStream类代码示例

本文整理汇总了C#中MySql.Data.MySqlClient.MySqlStream的典型用法代码示例。如果您正苦于以下问题:C# MySqlStream类的具体用法?C# MySqlStream怎么用?C# MySqlStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MySqlStream类属于MySql.Data.MySqlClient命名空间,在下文中一共展示了MySqlStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
            bool negative = ts.TotalMilliseconds < 0;
            ts = ts.Duration();

			if (binary)
			{
				stream.WriteByte(8);
				stream.WriteByte((byte)(negative ? 1 : 0));
				stream.WriteInteger(ts.Days, 4);
				stream.WriteByte((byte)ts.Hours);
				stream.WriteByte((byte)ts.Minutes);
				stream.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);

				stream.WriteStringNoNull(s);
			}
		}
开发者ID:epdumitru,项目名称:mysqlib,代码行数:26,代码来源:MySqlTime.cs

示例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());
		}
开发者ID:tdhieu,项目名称:openvss,代码行数:8,代码来源:MySqlInt16.cs

示例3:

		void IMySqlValue.WriteValue(MySqlStream stream, bool binary, object val, int length)
		{
			byte v = ((IConvertible)val).ToByte(null);
            if (binary)
                stream.WriteByte((byte)v);
            else
                stream.WriteStringNoNull(v.ToString());
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:8,代码来源:MySqlUByte.cs

示例4: 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());
		}
开发者ID:maanshancss,项目名称:ClassLibrary,代码行数:8,代码来源:MySqlBit.cs

示例5:

		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));
		}
开发者ID:maanshancss,项目名称:ClassLibrary,代码行数:9,代码来源:MySqlSingle.cs

示例6: SSPI

 public SSPI(string targetName, MySqlStream stream, int seqNo, DBVersion version)
 {
   this.targetName = null;
   this.stream = stream;
   packetHeader = new byte[4];
   seq = seqNo;
   this.version = version;
 }
开发者ID:BjkGkh,项目名称:R106,代码行数:8,代码来源:SSPI.cs

示例7: 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);
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:9,代码来源:parameter.cs

示例8: StartSSL

    private void StartSSL()
    {
      RemoteCertificateValidationCallback sslValidateCallback =
          new RemoteCertificateValidationCallback(ServerCheckValidation);
      SslStream ss = new SslStream(baseStream, true, sslValidateCallback, null);
      X509CertificateCollection certs = GetClientCertificates();
      ss.AuthenticateAsClient(Settings.Server, certs, SslProtocols.Default, false);
      baseStream = ss;
      stream = new MySqlStream(ss, Encoding, false);
      stream.SequenceByte = 2;

    }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:12,代码来源:NativeDriver.cs

示例9:

		void IMySqlValue.SkipValue(MySqlStream stream)
		{
			int len = stream.ReadByte();
			stream.SkipBytes(len);
		}
开发者ID:maanshancss,项目名称:ClassLibrary,代码行数:5,代码来源:MySqlTime.cs

示例10: if

		void IMySqlValue.WriteValue(MySqlStream stream, bool binary, object value, int length)
		{
			MySqlDateTime dtValue;

			if (value is DateTime)
				dtValue = new MySqlDateTime(type, (DateTime)value);
			else if (value is string)
				dtValue = new MySqlDateTime(type, DateTime.Parse((string)value,
					 System.Globalization.CultureInfo.CurrentCulture));
			else if (value is MySqlDateTime)
				dtValue = (MySqlDateTime)value;
			else
				throw new MySqlException("Unable to serialize date/time value.");

			if (!binary)
			{
				SerializeText(stream, dtValue);
				return;
			}

			if (type == MySqlDbType.Timestamp)
				stream.WriteByte(11);
			else
				stream.WriteByte(7);

			stream.WriteInteger(dtValue.Year, 2);
			stream.WriteByte((byte)dtValue.Month);
			stream.WriteByte((byte)dtValue.Day);
			if (type == MySqlDbType.Date)
			{
				stream.WriteByte(0);
				stream.WriteByte(0);
				stream.WriteByte(0);
			}
			else
			{
				stream.WriteByte((byte)dtValue.Hour);
				stream.WriteByte((byte)dtValue.Minute);
				stream.WriteByte((byte)dtValue.Second);
			}

			if (type == MySqlDbType.Timestamp)
				stream.WriteInteger(dtValue.Millisecond, 4);
		}
开发者ID:maanshancss,项目名称:ClassLibrary,代码行数:44,代码来源:MySqlDateTime.cs

示例11: 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 + "'");
		}
开发者ID:maanshancss,项目名称:ClassLibrary,代码行数:17,代码来源:MySqlDateTime.cs

示例12:

		IMySqlValue IMySqlValue.ReadValue(MySqlStream stream, long length, bool nullVal)
		{
			if (nullVal)
				return new MySqlUInt32((this as IMySqlValue).MySqlDbType, true);

			if (length == -1)
				return new MySqlUInt32((this as IMySqlValue).MySqlDbType,
					 (uint)stream.ReadInteger(4));
			else
				return new MySqlUInt32((this as IMySqlValue).MySqlDbType,
					 UInt32.Parse(stream.ReadString(length), NumberStyles.Any, CultureInfo.InvariantCulture));
		}
开发者ID:maanshancss,项目名称:ClassLibrary,代码行数:12,代码来源:MySqlUInt32.cs

示例13:

		IMySqlValue IMySqlValue.ReadValue(MySqlStream stream, long length, bool nullVal)
		{
			if (nullVal)
				return new MySqlInt64(true);

			if (length == -1)
				return new MySqlInt64((long)stream.ReadLong(8));
			else
				return new MySqlInt64(Int64.Parse(stream.ReadString(length)));
		}
开发者ID:tdhieu,项目名称:openvss,代码行数:10,代码来源:MySqlInt64.cs

示例14: SerializeParameter

        /// <summary>
        /// Serializes the given parameter to the given memory stream
        /// </summary>
        /// <remarks>
        /// <para>This method is called by PrepareSqlBuffers to convert the given
        /// parameter to bytes and write those bytes to the given memory stream.
        /// </para>
        /// </remarks>
        /// <returns>True if the parameter was successfully serialized, false otherwise.</returns>
        private bool SerializeParameter(MySqlParameterCollection parameters,
            MySqlStream stream, string parmName)
        {
            MySqlParameter parameter = GetParameter(parameters, parmName);
            if (parameter == null)
            {
                // if we are using old syntax, we can't throw exceptions for parameters
                // not defined.
                if (Connection.Settings.UseOldSyntax)
                    return false;
                throw new MySqlException(
                    String.Format(Resources.ParameterMustBeDefined, parmName));
            }

            parameter.Serialize(stream, false);
            return true;
        }
开发者ID:rykr,项目名称:connector-net,代码行数:26,代码来源:Statement.cs

示例15: BindParameters

        protected virtual void BindParameters()
        {
            // tokenize the sql
            ArrayList tokenArray = TokenizeSql(ResolvedCommandText);

            MySqlStream stream = new MySqlStream(Driver.Encoding);
            stream.Version = Driver.Version;

            // make sure our token array ends with a ;
            string lastToken = (string) tokenArray[tokenArray.Count - 1];
            if (lastToken != ";")
                tokenArray.Add(";");

            foreach (String token in tokenArray)
            {
                if (token.Trim().Length == 0)
                    continue;
                if (token == ";")
                {
                    buffers.Add(stream.InternalBuffer);
                    stream = new MySqlStream(Driver.Encoding);
                    continue;
                }
                if (token[0] == Parameters.ParameterMarker)
                {
                    if (SerializeParameter(Parameters, stream, token))
                        continue;
                }

                // our fall through case is to write the token to the byte stream
                stream.WriteStringNoNull(token);
            }
        }
开发者ID:rykr,项目名称:connector-net,代码行数:33,代码来源:Statement.cs


注:本文中的MySql.Data.MySqlClient.MySqlStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。