Ejemplo n.º 1
0
        private static byte[] CreateConnectionAttributes()
        {
            var attributesWriter = new PayloadWriter();

            attributesWriter.WriteLengthEncodedString("_client_name");
            attributesWriter.WriteLengthEncodedString("MySqlConnector");
            attributesWriter.WriteLengthEncodedString("_client_version");
            attributesWriter.WriteLengthEncodedString(typeof(ServerSession).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion);
            try
            {
                Utility.GetOSDetails(out var os, out var osDescription, out var architecture);
                if (os != null)
                {
                    attributesWriter.WriteLengthEncodedString("_os");
                    attributesWriter.WriteLengthEncodedString(os);
                }
                attributesWriter.WriteLengthEncodedString("_os_details");
                attributesWriter.WriteLengthEncodedString(osDescription);
                attributesWriter.WriteLengthEncodedString("_platform");
                attributesWriter.WriteLengthEncodedString(architecture);
            }
            catch (PlatformNotSupportedException)
            {
            }
            using (var process = Process.GetCurrentProcess())
            {
                attributesWriter.WriteLengthEncodedString("_pid");
                attributesWriter.WriteLengthEncodedString(process.Id.ToString(CultureInfo.InvariantCulture));
            }
            var connectionAttributes = attributesWriter.ToBytes();

            var writer = new PayloadWriter();

            writer.WriteLengthEncodedInteger((ulong)connectionAttributes.Length);
            writer.Write(connectionAttributes);
            return(writer.ToBytes());
        }