public static INativeProxy GetProxy(INativeTracer nativeTracer) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return(new NativeImportsWin32(nativeTracer)); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { return(new NativeImportsLinux(nativeTracer)); } else { throw new NotSupportedException(); } }
public NativeConnection(string dllPath, INativeTracer nativeTracer) { _nativeProxy = NativeProxyFactory.GetProxy(nativeTracer); if (!string.IsNullOrWhiteSpace(dllPath) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { lock (Win32PathsAlreadyAdded) { if (!Win32PathsAlreadyAdded.Contains(dllPath)) { var p = Environment.GetEnvironmentVariable("PATH"); Environment.SetEnvironmentVariable("PATH", p + ";" + dllPath, EnvironmentVariableTarget.Process); Win32PathsAlreadyAdded.Add(dllPath); } } } if (IntPtr.Size == sizeof(int)) { throw new Exception("32Bit process is not supported"); } if (!_mysqlServerInitCalled) { int rv = _nativeProxy.mysql_server_init(0, IntPtr.Zero, IntPtr.Zero); if (rv != 0) { throw new MySqlException("Could not initialize MySQL client library"); } _mysqlServerInitCalled = true; } MySql = _nativeProxy.mysql_init(IntPtr.Zero); if (MySql == null) { throw new MySqlException("mysql_init failed"); } IntPtr vers = mysql_get_client_info(); if (vers == null) { throw new MySqlException("mysql_get_client_info failed"); } ClientVersion = Marshal.PtrToStringAnsi(vers); }
public static void SetDefaultNativeTracer(INativeTracer nativeTracer) { _defaultNativeTracer = nativeTracer; }
public void SetNativeTracer(INativeTracer nativeTracer) { _currentNativeTracer = nativeTracer; }
internal NativeImportsLinux(INativeTracer nativeTracer) { _nativeTracer = nativeTracer; }
internal NativeImportsWin32(INativeTracer nativeTracer) { _nativeTracer = nativeTracer; }
internal NativeImportsTemplate(INativeTracer nativeTracer) { _nativeTracer = nativeTracer; }