Exemplo n.º 1
0
 public NativeStatement(NativeConnection nativeConnection, INativeProxy nativeProxy)
 {
     _nativeConnection = nativeConnection;
     _nativeProxy      = nativeProxy;
     stmt = mysql_stmt_init(_nativeConnection.MySql);
     if (stmt == IntPtr.Zero)
     {
         throw new MySqlException(_nativeConnection);
     }
 }
        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);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkyService" /> class.
 /// </summary>
 public SkyService(INativeProxy <SkyServiceNative> nativeProxy)
 {
     _native = nativeProxy.Instance;
 }
Exemplo n.º 4
0
 public void OnGameModeInit(INativeProxy <TestNatives> m)
 {
     Console.WriteLine("About to call a remote func!");
     // TODO: This can crash; need to investigate.
     m.Instance.CallRemoteFunction("TestCallback", "dd", 1, 2);
 }
Exemplo n.º 5
0
 public bool RegisterListener(INativeProxy obj)
 {
     listener = obj;
     return(true);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldService" /> class.
 /// </summary>
 public WorldService(IEntityManager entityManager, INativeProxy <WorldServiceNative> nativeProxy)
 {
     _entityManager = entityManager;
     _native        = nativeProxy.Instance;
 }
Exemplo n.º 7
0
 /// <inheritdoc />
 public ServerService(INativeProxy <ServerServiceNative> nativeProxy,
                      INativeProxy <VariableCollection.ServerVariableCollectionNatives> serverVariablesNativeProxy)
 {
     _native   = nativeProxy.Instance;
     Variables = new VariableCollection(serverVariablesNativeProxy.Instance);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="YsfService" /> class.
 /// </summary>
 public YsfService(INativeProxy <YsfServiceNative> nativeProxy)
 {
     _native = nativeProxy.Instance;
 }
Exemplo n.º 9
0
 public void OnGameModeInit(INativeProxy <TestNatives> m)
 {
     Console.WriteLine("About to call a remote func!");
     m.Instance.CallRemoteFunction("TestCallback", "ddd", 1, 2, 3);
 }