Advertisement
Serafim

Untitled

Aug 27th, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.52 KB | None | 0 0
  1. // Кусок на шарпе
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Net.Sockets;
  7. using System.Net;
  8. using System.Diagnostics;
  9. using System.IO;
  10. using System.Windows.Forms;
  11. using System.Runtime.InteropServices;
  12.  
  13. namespace Xphp
  14. {
  15.  
  16.     class PhpWrapper
  17.     {
  18.         // wrapper instance
  19.         private static PhpWrapper _instance = null;
  20.  
  21.         // process
  22.         private int _port;
  23.         public int port
  24.         {
  25.             get { return _port; }
  26.         }
  27.  
  28.         // wrapper path
  29.         private String _path;
  30.  
  31.         // process
  32.         private Process _process = null;
  33.         public Process process
  34.         {
  35.             get { return _process; }
  36.         }
  37.  
  38.         public static PhpWrapper getInstance()
  39.         {
  40.             if (_instance == null) {
  41.                 _instance = new PhpWrapper();
  42.             }
  43.             return _instance;
  44.         }
  45.  
  46.         public PhpWrapper()
  47.         {
  48.             _port = this._getPort();
  49.             _path = Config.path + Config.phpPath;
  50.             this.run();
  51.         }
  52.  
  53.         public static void halt()
  54.         {
  55.             if (getInstance().process != null)
  56.             {
  57.                 System.Console.WriteLine("Stop server.");
  58.                 getInstance().process.Kill();
  59.             }
  60.         }
  61.  
  62.  
  63. // Кусок на пыхе
  64.  
  65. use System;
  66. use System\Collections\Generic;
  67. use System\Linq;
  68. use System\Text;
  69. use System\Net\Sockets;
  70. use System\Net;
  71. use System\Diagnostics;
  72. use System\IO;
  73. use System\Windows\Forms;
  74. use System\Runtime\InteropServices;
  75.  
  76. namespace Xphp
  77. {
  78.  
  79.     class PhpWrapper
  80.     {
  81.         // wrapper instance
  82.         private static $_instance = null;
  83.  
  84.         // process
  85.         private $_port;
  86.  
  87.         // wrapper path
  88.         private $_path;
  89.  
  90.         // process
  91.         private $_process = null;
  92.  
  93.  
  94.         public static function getInstance()
  95.         {
  96.             if ($this->_instance == null) {
  97.                 $this->_instance = new PhpWrapper();
  98.             }
  99.             return $this->_instance;
  100.         }
  101.  
  102.         public function __construct()
  103.         {
  104.             _port = $this->_getPort();
  105.             _path = Config::$path . Config::$phpPath;
  106.             $this->run();
  107.         }
  108.  
  109.         public static halt()
  110.         {
  111.             if ($this->getInstance()->_process != null)
  112.             {
  113.                 System\Console::WriteLine("Stop server.");
  114.                 $this->getInstance()->process->Kill();
  115.             }
  116.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement