internal void SetConnectAttrs() { // Sets connect attributes if ((connectionFlags & ClientFlags.CONNECT_ATTRS) != 0) { string connectAttrs = string.Empty; MySqlConnectAttrs attrs = new MySqlConnectAttrs(); foreach (PropertyInfo property in attrs.GetType().GetProperties()) { string name = property.Name; object[] customAttrs = property.GetCustomAttributes(typeof(DisplayNameAttribute), false).ToArray <object>(); if (customAttrs.Length > 0) { name = (customAttrs[0] as DisplayNameAttribute).DisplayName; } string value = (string)property.GetValue(attrs, null); connectAttrs += string.Format("{0}{1}", (char)name.Length, name); connectAttrs += string.Format("{0}{1}", (char)value.Length, value); } packet.WriteLenString(connectAttrs); } }
internal void SetConnectAttrs() { if ((this.connectionFlags & ClientFlags.CONNECT_ATTRS) != (ClientFlags)0uL) { string text = string.Empty; MySqlConnectAttrs mySqlConnectAttrs = new MySqlConnectAttrs(); PropertyInfo[] properties = mySqlConnectAttrs.GetType().GetProperties(); for (int i = 0; i < properties.Length; i++) { PropertyInfo propertyInfo = properties[i]; string text2 = propertyInfo.Name; object[] customAttributes = propertyInfo.GetCustomAttributes(typeof(DisplayNameAttribute), false); if (customAttributes.Length > 0) { text2 = (customAttributes[0] as DisplayNameAttribute).DisplayName; } string text3 = (string)propertyInfo.GetValue(mySqlConnectAttrs, null); text += string.Format("{0}{1}", (char)text2.Length, text2); text += string.Format("{0}{1}", (char)text3.Length, text3); } this.packet.WriteLenString(text); } }
internal void SetConnectAttrs() { // Sets connect attributes if ((connectionFlags & ClientFlags.CONNECT_ATTRS) != 0) { string connectAttrs = string.Empty; MySqlConnectAttrs attrs = new MySqlConnectAttrs(); foreach (PropertyInfo property in attrs.GetType().GetProperties()) { string name = property.Name; #if RT object[] customAttrs = property.GetCustomAttributes(typeof(DisplayNameAttribute), false).ToArray<object>(); #else object[] customAttrs = property.GetCustomAttributes(typeof(DisplayNameAttribute), false); #endif if (customAttrs.Length > 0) name = (customAttrs[0] as DisplayNameAttribute).DisplayName; string value = (string)property.GetValue(attrs, null); connectAttrs += string.Format("{0}{1}", (char)name.Length, name); connectAttrs += string.Format("{0}{1}", (char)value.Length, value); } packet.WriteLenString(connectAttrs); } }
public void ConnectAttributes() { if (Version < new Version(5, 6, 6)) return; using (MySqlConnection connection = new MySqlConnection(GetConnectionString(rootUser, rootPassword, false))) { connection.Open(); if (connection.driver.SupportsConnectAttrs) { MySqlCommand cmd = new MySqlCommand("SELECT * FROM performance_schema.session_connect_attrs WHERE PROCESSLIST_ID = connection_id()", connection); MySqlDataReader dr = cmd.ExecuteReader(); Assert.True(dr.HasRows, "No session_connect_attrs found"); MySqlConnectAttrs connectAttrs = new MySqlConnectAttrs(); bool isValidated = false; while (dr.Read()) { if (dr.GetString(1) == "_client_name") { Assert.AreEqual(connectAttrs.ClientName, dr.GetString(2)); isValidated = true; break; } } Assert.True(isValidated, "Missing _client_version attribute"); } } }