コード例 #1
0
ファイル: CharSetMap.cs プロジェクト: zwdgithub/NovelGetter
        public static Encoding GetEncoding(DBVersion version, string CharSetName)
        {
            Encoding encoding;

            try
            {
                CharacterSet chararcterSet = CharSetMap.GetChararcterSet(version, CharSetName);
                encoding = Encoding.GetEncoding(chararcterSet.name);
            }
            catch (NotSupportedException)
            {
                encoding = Encoding.GetEncoding(0);
            }
            return(encoding);
        }
コード例 #2
0
ファイル: NativeDriver.cs プロジェクト: vinicius-zhu/EUO
        private MySqlField GetFieldMetaData41()
        {
            MySqlField field = new MySqlField(this.connection);

            stream.OpenPacket();
            field.Encoding           = encoding;
            field.CatalogName        = stream.ReadLenString();
            field.DatabaseName       = stream.ReadLenString();
            field.TableName          = stream.ReadLenString();
            field.RealTableName      = stream.ReadLenString();
            field.ColumnName         = stream.ReadLenString();
            field.OriginalColumnName = stream.ReadLenString();
            byte b = (byte)stream.ReadByte();

            field.CharacterSetIndex = stream.ReadInteger(2);
            field.ColumnLength      = stream.ReadInteger(4);
            MySqlDbType type = (MySqlDbType)stream.ReadByte();
            ColumnFlags colFlags;

            if ((Flags & ClientFlags.LONG_FLAG) != 0)
            {
                colFlags = (ColumnFlags)stream.ReadInteger(2);
            }
            else
            {
                colFlags = (ColumnFlags)stream.ReadByte();
            }

            field.SetTypeAndFlags(type, colFlags);

            field.Scale = (byte)stream.ReadByte();


            if (stream.HasMoreData)
            {
                int reserved = stream.ReadInteger(2);   // reserved
            }

            if (charSets != null)
            {
                CharacterSet cs = CharSetMap.GetChararcterSet(this.Version, (string)charSets[field.CharacterSetIndex]);
                field.MaxLength = cs.byteCount;
                field.Encoding  = CharSetMap.GetEncoding(this.version, (string)charSets[field.CharacterSetIndex]);
            }

            return(field);
        }
コード例 #3
0
ファイル: NativeDriver.cs プロジェクト: zwdgithub/NovelGetter
        private MySqlField GetFieldMetaData41()
        {
            MySqlField mySqlField = new MySqlField(base.Version);

            this.reader.OpenPacket();
            mySqlField.Encoding           = this.encoding;
            mySqlField.CatalogName        = this.reader.ReadLenString();
            mySqlField.DatabaseName       = this.reader.ReadLenString();
            mySqlField.TableName          = this.reader.ReadLenString();
            mySqlField.RealTableName      = this.reader.ReadLenString();
            mySqlField.ColumnName         = this.reader.ReadLenString();
            mySqlField.OriginalColumnName = this.reader.ReadLenString();
            this.reader.ReadByte();
            mySqlField.CharacterSetIndex = this.reader.ReadInteger(2);
            mySqlField.ColumnLength      = this.reader.ReadInteger(4);
            MySqlDbType type = (MySqlDbType)this.reader.ReadByte();
            ColumnFlags flags;

            if ((this.Flags & ClientFlags.LONG_FLAG) != (ClientFlags)0)
            {
                flags = (ColumnFlags)this.reader.ReadInteger(2);
            }
            else
            {
                flags = (ColumnFlags)this.reader.ReadByte();
            }
            mySqlField.SetTypeAndFlags(type, flags);
            mySqlField.Scale = (byte)this.reader.ReadByte();
            if (this.charSets != null)
            {
                CharacterSet chararcterSet = CharSetMap.GetChararcterSet(base.Version, (string)this.charSets[mySqlField.CharacterSetIndex]);
                mySqlField.MaxLength = chararcterSet.byteCount;
                mySqlField.Encoding  = CharSetMap.GetEncoding(this.version, (string)this.charSets[mySqlField.CharacterSetIndex]);
            }
            return(mySqlField);
        }