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


C# MySqlPacket.WriteByte方法代码示例

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


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

示例1:

 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:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:MySqlUByte.cs

示例2: MySqlDateTime

    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

示例3: 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

示例4: MySqlException

        void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
        {
            byte[] buffToWrite = (val as byte[]);
            if (buffToWrite == null)
            {
                char[] valAsChar = (val as Char[]);
                if (valAsChar != null)
                    buffToWrite = packet.Encoding.GetBytes(valAsChar);
                else
                {
                    string s = val.ToString();
                    if (length == 0)
                        length = s.Length;
                    else
                        s = s.Substring(0, length);
                    buffToWrite = packet.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)
            {
                packet.WriteLength(length);
                packet.Write(buffToWrite, 0, length);
            }
            else
            {
                if (packet.Version.isAtLeast(4, 1, 0))
                    packet.WriteStringNoNull("_binary ");

                packet.WriteByte((byte)'\'');
                EscapeByteArray(buffToWrite, length, packet);
                packet.WriteByte((byte)'\'');
            }
        }
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:41,代码来源:MySqlBinary.cs

示例5: 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

示例6: InternalBindParameters

        private void InternalBindParameters(string sql, MySqlParameterCollection parameters, 
            MySqlPacket packet)
        {
            bool sqlServerMode = command.Connection.Settings.SqlServerMode;

            if (packet == null)
            {
                packet = new MySqlPacket(Driver.Encoding);
                packet.Version = Driver.Version;
                packet.WriteByte(0);
            }

            MySqlTokenizer tokenizer = new MySqlTokenizer(sql);
            tokenizer.ReturnComments = true;
            tokenizer.SqlServerMode = sqlServerMode;

            int pos = 0;
            string token = tokenizer.NextToken();
            while (token != null)
            {
                // serialize everything that came before the token (i.e. whitespace)
                packet.WriteStringNoNull(sql.Substring(pos, tokenizer.StartIndex - pos));
                pos = tokenizer.StopIndex;
                if (MySqlTokenizer.IsParameter(token))
                {
                    if (SerializeParameter(parameters, packet, token))
                        token = null;
                }
                if (token != null)
                {
                    if (sqlServerMode && tokenizer.Quoted && token.StartsWith("["))
                        token = String.Format("`{0}`", token.Substring(1, token.Length - 2));
                    packet.WriteStringNoNull(token);
                }
                token = tokenizer.NextToken();
            }
            buffers.Add(packet);
        }
开发者ID:seeseekey,项目名称:CSCL,代码行数:38,代码来源:Statement.cs

示例7: WriteOldGuid

    private void WriteOldGuid(MySqlPacket packet, Guid guid, bool binary)
    {
      byte[] bytes = guid.ToByteArray();

      if (binary)
      {
        packet.WriteLength(bytes.Length);
        packet.Write(bytes);
      }
      else
      {
        packet.WriteStringNoNull("_binary ");
        packet.WriteByte((byte)'\'');
        EscapeByteArray(bytes, bytes.Length, packet);
        packet.WriteByte((byte)'\'');
      }
    }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:17,代码来源:MySqlGuid.cs

示例8: Open


//.........这里部分代码省略.........
      catch (Exception ex)
      {
        throw new MySqlException(Resources.UnableToConnectToHost,
            (int)MySqlErrorCode.UnableToConnectToHost, ex);
      }
      if (baseStream == null)
        throw new MySqlException(Resources.UnableToConnectToHost,
            (int)MySqlErrorCode.UnableToConnectToHost);

      int maxSinglePacket = 255 * 255 * 255;
      stream = new MySqlStream(baseStream, Encoding, false);

      stream.ResetTimeout((int)Settings.ConnectionTimeout * 1000);

      // read off the welcome packet and parse out it's values
      packet = stream.ReadPacket();
      int protocol = packet.ReadByte();
      string versionString = packet.ReadString();
      version = DBVersion.Parse(versionString);
      if (!version.isAtLeast(5, 0, 0))
        throw new NotSupportedException(Resources.ServerTooOld);
      threadId = packet.ReadInteger(4);
      encryptionSeed = packet.ReadString();

      maxSinglePacket = (256 * 256 * 256) - 1;

      // read in Server capabilities if they are provided
      ClientFlags serverCaps = 0;
      if (packet.HasMoreData)
        serverCaps = (ClientFlags)packet.ReadInteger(2);

      /* New protocol with 16 bytes to describe server characteristics */
      owner.ConnectionCharSetIndex = (int)packet.ReadByte();

      serverStatus = (ServerStatusFlags)packet.ReadInteger(2);

      // Since 5.5, high bits of server caps are stored after status.
      // Previously, it was part of reserved always 0x00 13-byte filler.
      uint serverCapsHigh = (uint)packet.ReadInteger(2);
      serverCaps |= (ClientFlags)(serverCapsHigh << 16);

      packet.Position += 11;
      string seedPart2 = packet.ReadString();
      encryptionSeed += seedPart2;

      string authenticationMethod = "";
      if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
      {
        authenticationMethod = packet.ReadString();
      }
      else
      {
        // Some MySql versions like 5.1, don't give name of plugin, default to native password.
        authenticationMethod = "mysql_native_password";
      }

      // based on our settings, set our connection flags
      SetConnectionFlags(serverCaps);

      packet.Clear();
      packet.WriteInteger((int)connectionFlags, 4);

#if !CF
      if ((serverCaps & ClientFlags.SSL) == 0)
      {
        if ((Settings.SslMode != MySqlSslMode.None)
        && (Settings.SslMode != MySqlSslMode.Preferred))
        {
          // Client requires SSL connections.
          string message = String.Format(Resources.NoServerSSLSupport,
              Settings.Server);
          throw new MySqlException(message);
        }
      }
      else if (Settings.SslMode != MySqlSslMode.None)
      {
        stream.SendPacket(packet);
        StartSSL();
        packet.Clear();
        packet.WriteInteger((int)connectionFlags, 4);
      }
#endif

      packet.WriteInteger(maxSinglePacket, 4);
      packet.WriteByte(8);
      packet.Write(new byte[23]);

      Authenticate(authenticationMethod, false);

      // if we are using compression, then we use our CompressedStream class
      // to hide the ugliness of managing the compression
      if ((connectionFlags & ClientFlags.COMPRESS) != 0)
        stream = new MySqlStream(baseStream, Encoding, true);

      // give our stream the server version we are connected to.  
      // We may have some fields that are read differently based 
      // on the version of the server we are connected to.
      packet.Version = version;
      stream.MaxBlockSize = maxSinglePacket;
    }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:101,代码来源:NativeDriver.cs

示例9: 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

示例10: InternalBindParameters

        private void InternalBindParameters(string sql, MySqlParameterCollection parameters, 
            MySqlPacket packet)
        {
            if (packet == null)
            {
                packet = new MySqlPacket(Driver.Encoding);
                packet.Version = Driver.Version;
                packet.WriteByte(0);
            }

            int startPos = 0;
            MySqlTokenizer tokenizer = new MySqlTokenizer(sql);
            tokenizer.ReturnComments = true;
            string parameter = tokenizer.NextParameter();
            while (parameter != null)
            {
                packet.WriteStringNoNull(sql.Substring(startPos, tokenizer.StartIndex - startPos));
                bool serialized = SerializeParameter(parameters, packet, parameter);
                startPos = tokenizer.StopIndex;
                if (!serialized)
                    startPos = tokenizer.StartIndex;
                parameter = tokenizer.NextParameter();
            }
            packet.WriteStringNoNull(sql.Substring(startPos));
            buffers.Add(packet);
        }
开发者ID:zibler,项目名称:zibler,代码行数:26,代码来源:Statement.cs

示例11: MySqlGeometry

        void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
        {
            byte[] buffToWrite = null;

              try
              {
            buffToWrite = ((MySqlGeometry)val)._valBinary;
              }
              catch
              {
            buffToWrite = val as Byte[];
              }

              if (buffToWrite == null)
              {
            MySqlGeometry v = new MySqlGeometry(0, 0);
            MySqlGeometry.TryParse(val.ToString(), out v);
            buffToWrite = v._valBinary;
              }

              byte[] result = new byte[GEOMETRY_LENGTH];

              for (int i = 0; i < buffToWrite.Length; i++)
              {
               if (buffToWrite.Length < GEOMETRY_LENGTH)
             result[i + 4] = buffToWrite[i];
               else
            result[i] = buffToWrite[i];
              }

            packet.WriteStringNoNull("_binary ");
            packet.WriteByte((byte)'\'');
            EscapeByteArray(result, GEOMETRY_LENGTH, packet);
            packet.WriteByte((byte)'\'');
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:35,代码来源:MySqlGeometry.cs

示例12: InternalBindParameters

        private void InternalBindParameters(string sql, MySqlParameterCollection parameters,
        MySqlPacket packet)
        {
            bool sqlServerMode = command.Connection.Settings.SqlServerMode;

              if (packet == null)
              {
            packet = new MySqlPacket(Driver.Encoding);
            packet.Version = Driver.Version;
            packet.WriteByte(0);
              }

              MySqlTokenizer tokenizer = new MySqlTokenizer(sql);
              tokenizer.ReturnComments = true;
              tokenizer.SqlServerMode = sqlServerMode;

              int pos = 0;
              string token = tokenizer.NextToken();
              int parameterCount = 0;
              while (token != null)
              {
            // serialize everything that came before the token (i.e. whitespace)
            packet.WriteStringNoNull(sql.Substring(pos, tokenizer.StartIndex - pos));
            pos = tokenizer.StopIndex;
            if (MySqlTokenizer.IsParameter(token))
            {
              if ((!parameters.containsUnnamedParameters && token.Length == 1 && parameterCount > 0) || parameters.containsUnnamedParameters && token.Length > 1)
            throw new MySqlException("Resources.MixedParameterNamingNotAllowed");

              parameters.containsUnnamedParameters = token.Length == 1;
              if (SerializeParameter(parameters, packet, token, parameterCount))
            token = null;
              parameterCount++;
            }
            if (token != null)
            {
              if (sqlServerMode && tokenizer.Quoted && token.StartsWith("[", StringComparison.Ordinal))
            token = String.Format("`{0}`", token.Substring(1, token.Length - 2));
              packet.WriteStringNoNull(token);
            }
            token = tokenizer.NextToken();
              }
              buffers.Add(packet);
        }
开发者ID:GamesDesignArt,项目名称:DotnetSpider,代码行数:44,代码来源:Statement.cs

示例13: Open

        public void Open()
        {
            // connect to one of our specified hosts
            try
            {
                baseStream = StreamCreator.GetStream(Settings);
                //#if !CF && !RT
                //         if (Settings.IncludeSecurityAsserts)
                //            MySqlSecurityPermission.CreatePermissionSet(false).Assert();
                //#endif
            }
            catch (System.Security.SecurityException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new MySqlException("Resources.UnableToConnectToHost",
                    (int)MySqlErrorCode.UnableToConnectToHost, ex);
            }
            if (baseStream == null)
                throw new MySqlException("Resources.UnableToConnectToHost",
                    (int)MySqlErrorCode.UnableToConnectToHost);

            int maxSinglePacket = 255 * 255 * 255;
            stream = new MySqlStream(baseStream, Encoding, false);

            stream.ResetTimeout((int)Settings.ConnectionTimeout * 1000);

            // read off the welcome packet and parse out it's values
            packet = stream.ReadPacket();
            int protocol = packet.ReadByte();
            string versionString = packet.ReadString();
            owner.isFabric = versionString.EndsWith("fabric", StringComparison.OrdinalIgnoreCase);
            version = DBVersion.Parse(versionString);
            if (!owner.isFabric && !version.isAtLeast(5, 0, 0))
                throw new NotSupportedException("Resources.ServerTooOld");

            threadId = packet.ReadInteger(4);

            byte[] seedPart1 = packet.ReadStringAsBytes();

            maxSinglePacket = (256 * 256 * 256) - 1;

            // read in Server capabilities if they are provided
            ClientFlags serverCaps = 0;
            if (packet.HasMoreData)
                serverCaps = (ClientFlags)packet.ReadInteger(2);

            /* New protocol with 16 bytes to describe server characteristics */
            owner.ConnectionCharSetIndex = (int)packet.ReadByte();

            serverStatus = (ServerStatusFlags)packet.ReadInteger(2);

            // Since 5.5, high bits of server caps are stored after status.
            // Previously, it was part of reserved always 0x00 13-byte filler.
            uint serverCapsHigh = (uint)packet.ReadInteger(2);
            serverCaps |= (ClientFlags)(serverCapsHigh << 16);

            packet.Position += 11;
            byte[] seedPart2 = packet.ReadStringAsBytes();
            encryptionSeed = new byte[seedPart1.Length + seedPart2.Length];
            seedPart1.CopyTo(encryptionSeed, 0);
            seedPart2.CopyTo(encryptionSeed, seedPart1.Length);

            string authenticationMethod = "";
            if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
            {
                authenticationMethod = packet.ReadString();
            }
            else
            {
                // Some MySql versions like 5.1, don't give name of plugin, default to native password.
                authenticationMethod = "mysql_native_password";
            }

            // based on our settings, set our connection flags
            SetConnectionFlags(serverCaps);

            packet.Clear();
            packet.WriteInteger((int)connectionFlags, 4);
            packet.WriteInteger(maxSinglePacket, 4);
            packet.WriteByte(33); //character set utf-8
            packet.Write(new byte[23]);

            #if !CF && !RT
            if ((serverCaps & ClientFlags.SSL) == 0)
            {
                if ((Settings.SslMode != MySqlSslMode.None)
                && (Settings.SslMode != MySqlSslMode.Preferred))
                {
                    // Client requires SSL connections.
                    string message = String.Format("Resources.NoServerSSLSupport",

                        Settings.Server);
                    throw new MySqlException(message);
                }
            }
            else if (Settings.SslMode != MySqlSslMode.None)
            {
//.........这里部分代码省略.........
开发者ID:yalunwang,项目名称:DotnetSpider,代码行数:101,代码来源:NativeDriver.cs

示例14: MySqlDateTime

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

            string valueAsString = value as string;

            if (value is DateTime)
                dtValue = new MySqlDateTime(type, (DateTime)value);
            else if (valueAsString != null)
                dtValue = new MySqlDateTime(type, DateTime.Parse(valueAsString, CultureInfo.CurrentCulture));
            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 (type == MySqlDbType.Timestamp)
                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 (type == MySqlDbType.Timestamp)
                packet.WriteInteger(dtValue.Millisecond, 4);
        }
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:45,代码来源:MySqlDateTime.cs

示例15: Open

        public void Open()
        {
            // connect to one of our specified hosts
            try
            {
            #if !CF
                if (Settings.ConnectionProtocol == MySqlConnectionProtocol.SharedMemory)
                {
                    SharedMemoryStream str = new SharedMemoryStream(Settings.SharedMemoryName);
                    str.Open(Settings.ConnectionTimeout);
                    baseStream = str;
                }
                else
                {
            #endif
                    string pipeName = Settings.PipeName;
                    if (Settings.ConnectionProtocol != MySqlConnectionProtocol.NamedPipe)
                        pipeName = null;
                    StreamCreator sc = new StreamCreator(Settings.Server, Settings.Port, pipeName,
                        Settings.Keepalive);
                    baseStream = sc.GetStream(Settings.ConnectionTimeout);
            #if !CF
                }
            #endif
            }
            catch (Exception ex)
            {
                    throw new MySqlException(MySqlResources.UnableToConnectToHost,
                    (int) MySqlErrorCode.UnableToConnectToHost, ex);
            }

            if (baseStream == null)
                    throw new MySqlException(MySqlResources.UnableToConnectToHost,
                    (int)MySqlErrorCode.UnableToConnectToHost);

            int maxSinglePacket = 255*255*255;
            stream = new MySqlStream(baseStream, Encoding, false);

            stream.ResetTimeout((int)Settings.ConnectionTimeout*1000);

            // read off the welcome packet and parse out it's values
            packet = stream.ReadPacket();
            int protocol = packet.ReadByte();
            string versionString = packet.ReadString();
            version = DBVersion.Parse(versionString);
            if (!version.isAtLeast(4, 1, 1))
                    throw new NotSupportedException(MySqlResources.ServerTooOld);
            threadId = packet.ReadInteger(4);
            encryptionSeed = packet.ReadString();

            maxSinglePacket = (256*256*256) - 1;

            // read in Server capabilities if they are provided
            ClientFlags serverCaps = 0;
            if (packet.HasMoreData)
                serverCaps = (ClientFlags) packet.ReadInteger(2);

            /* New protocol with 16 bytes to describe server characteristics */
            owner.ConnectionCharSetIndex = (int)packet.ReadByte();

            serverStatus = (ServerStatusFlags) packet.ReadInteger(2);
            packet.Position += 13;
            string seedPart2 = packet.ReadString();
            encryptionSeed += seedPart2;

            // based on our settings, set our connection flags
            SetConnectionFlags(serverCaps);

            packet.Clear();
            packet.WriteInteger((int) connectionFlags, 4);

            #if !CF
            if ((serverCaps & ClientFlags.SSL) ==0)
            {
                if ((Settings.SslMode != MySqlSslMode.None)
                && (Settings.SslMode != MySqlSslMode.Preferred))
                {
                    // Client requires SSL connections.
                         string message = String.Format(MySqlResources.NoServerSSLSupport,
                        Settings.Server);
                    throw new MySqlException(message);
                }
            }
            else if (Settings.SslMode != MySqlSslMode.None)
            {
                stream.SendPacket(packet);
                StartSSL();
                packet.Clear();
                packet.WriteInteger((int) connectionFlags, 4);
            }
            #endif

            packet.WriteInteger(maxSinglePacket, 4);
            packet.WriteByte(8);
            packet.Write(new byte[23]);

            Authenticate();

            // if we are using compression, then we use our CompressedStream class
            // to hide the ugliness of managing the compression
//.........这里部分代码省略.........
开发者ID:TsahiCX,项目名称:Test1,代码行数:101,代码来源:NativeDriver.cs


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