當前位置: 首頁>>代碼示例>>C#>>正文


C# MySqlStream.ReadString方法代碼示例

本文整理匯總了C#中MySql.Data.MySqlClient.MySqlStream.ReadString方法的典型用法代碼示例。如果您正苦於以下問題:C# MySqlStream.ReadString方法的具體用法?C# MySqlStream.ReadString怎麽用?C# MySqlStream.ReadString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MySql.Data.MySqlClient.MySqlStream的用法示例。


在下文中一共展示了MySqlStream.ReadString方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MySqlSingle

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

            if (length == -1)
            {
                byte[] b = new byte[4];
                stream.Read(b, 0, 4);
                return new MySqlSingle(BitConverter.ToSingle(b, 0));
            }
            return new MySqlSingle(Single.Parse(stream.ReadString(length),
                     CultureInfo.InvariantCulture));
        }
開發者ID:rykr,項目名稱:connector-net,代碼行數:14,代碼來源:MySqlSingle.cs

示例2: MySqlInt16

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

			if (length == -1)
				return new MySqlInt16((short)stream.ReadInteger(2));
			else
				return new MySqlInt16(Int16.Parse(stream.ReadString(length)));
		}
開發者ID:tdhieu,項目名稱:openvss,代碼行數:10,代碼來源:MySqlInt16.cs

示例3: MySqlString

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

			string s = String.Empty;
			if (length == -1)
				s = stream.ReadLenString();
			else
				s = stream.ReadString(length);
			MySqlString str = new MySqlString(type, s);
			return str;
		}
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:13,代碼來源:MySqlString.cs

示例4: if

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

			if (length >= 0)
			{
				string value = stream.ReadString(length);
				ParseMySql(value, stream.Version.isAtLeast(4, 1, 0));
				return this;
			}

			long bufLength = stream.ReadByte();
			int negate = 0;
			if (bufLength > 0)
				negate = stream.ReadByte();

			isNull = false;
			if (bufLength == 0)
				isNull = true;
			else if (bufLength == 5)
				mValue = new TimeSpan(stream.ReadInteger(4), 0, 0, 0);
			else if (bufLength == 8)
				mValue = new TimeSpan(stream.ReadInteger(4),
					 stream.ReadByte(), stream.ReadByte(), stream.ReadByte());
			else
				mValue = new TimeSpan(stream.ReadInteger(4),
					 stream.ReadByte(), stream.ReadByte(), stream.ReadByte(),
					 stream.ReadInteger(4) / 1000000);

			if (negate == 1)
				mValue = mValue.Negate();
			return this;
		}
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:33,代碼來源:MySqlTime.cs

示例5: MySqlDecimal

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

			if (length == -1)
			{
				string s = stream.ReadLenString();
				return new MySqlDecimal(Decimal.Parse(s,
					 CultureInfo.InvariantCulture));
			}
			else
			{
				string s = stream.ReadString(length);
				return new MySqlDecimal(Decimal.Parse(s,
					 CultureInfo.InvariantCulture));
			}
		}
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:18,代碼來源:MySqlDecimal.cs

示例6: MySqlByte

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

			if (length == -1)
				return new MySqlByte((sbyte)stream.ReadByte());
			else
			{
				string s = stream.ReadString(length);
				MySqlByte b = new MySqlByte(SByte.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture));
                b.TreatAsBoolean = TreatAsBoolean;
                return b;
			}
		}
開發者ID:tdhieu,項目名稱:openvss,代碼行數:15,代碼來源:MySqlByte.cs

示例7: ParseMySql

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

			if (length >= 0)
			{
				string value = stream.ReadString(length);
				return ParseMySql(value, stream.Version.isAtLeast(4, 1, 0));
			}

			long bufLength = stream.ReadByte();
			int year = 0, month = 0, day = 0;
			int hour = 0, minute = 0, second = 0;

			if (bufLength >= 4)
			{
				year = stream.ReadInteger(2);
				month = stream.ReadByte();
				day = stream.ReadByte();
			}

			if (bufLength > 4)
			{
				hour = stream.ReadByte();
				minute = stream.ReadByte();
				second = stream.ReadByte();
			}

			if (bufLength > 7)
				stream.ReadInteger(4);

			return new MySqlDateTime(type, year, month, day, hour, minute, second);
		}
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:33,代碼來源:MySqlDateTime.cs

示例8: MySqlUInt32

		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

示例9: MySqlInt64

		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

示例10: Open

        public override void Open()
        {
            base.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);
                    baseStream = sc.GetStream(Settings.ConnectionTimeout);
#if !CF
                }
#endif
                if (baseStream == null)
                    throw new Exception();
            }
            catch (Exception ex)
            {
                throw new MySqlException(Resources.UnableToConnectToHost, 
                    (int) MySqlErrorCode.UnableToConnectToHost, ex);
            }

            if (baseStream == null)
                throw new MySqlException("Unable to connect to any of the specified MySQL hosts");

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

            // read off the welcome packet and parse out it's values
            stream.OpenPacket();
            protocol = stream.ReadByte();
            string versionString = stream.ReadString();
            version = DBVersion.Parse(versionString);
            threadId = stream.ReadInteger(4);
            encryptionSeed = stream.ReadString();

            if (version.isAtLeast(4, 0, 8))
                maxSinglePacket = (256*256*256) - 1;

            // read in Server capabilities if they are provided
            serverCaps = 0;
            if (stream.HasMoreData)
                serverCaps = (ClientFlags) stream.ReadInteger(2);
            if (version.isAtLeast(4, 1, 1))
            {
                /* New protocol with 16 bytes to describe server characteristics */
                serverCharSetIndex = stream.ReadInteger(1);

                serverStatus = (ServerStatusFlags) stream.ReadInteger(2);
                stream.SkipBytes(13);
                string seedPart2 = stream.ReadString();
                encryptionSeed += seedPart2;
            }

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

            stream.StartOutput(0, false);
            stream.WriteInteger((int) connectionFlags,
                                version.isAtLeast(4, 1, 0) ? 4 : 2);

#if !CF
            if (connectionString.UseSSL && (serverCaps & ClientFlags.SSL) != 0)
            {
                stream.Flush();

                StartSSL();

                stream.StartOutput(0, false);
                stream.WriteInteger((int) connectionFlags,
                                    version.isAtLeast(4, 1, 0) ? 4 : 2);
            }
#endif

            stream.WriteInteger(maxSinglePacket,
                                version.isAtLeast(4, 1, 0) ? 4 : 3);

            if (version.isAtLeast(4, 1, 1))
            {
                stream.WriteByte(8);
                stream.Write(new byte[23]);
            }

            Authenticate();

            // if we are using compression, then we use our CompressedStream class
            // to hide the ugliness of managing the compression
            if ((connectionFlags & ClientFlags.COMPRESS) != 0)
//.........這裏部分代碼省略.........
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:101,代碼來源:NativeDriver.cs

示例11: MySqlUByte

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

			if (length == -1)
				return new MySqlUByte((byte)stream.ReadByte());
			else
				return new MySqlUByte(Byte.Parse(stream.ReadString(length)));
		}
開發者ID:tdhieu,項目名稱:openvss,代碼行數:10,代碼來源:MySqlUByte.cs


注:本文中的MySql.Data.MySqlClient.MySqlStream.ReadString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。