/// <summary> /// Registers a resource that should be disposed of when the request is over. /// </summary> /// <param name="res">The resource.</param> internal static LinkedListNode<WeakReference> RegisterResource(PhpResource/*!*/res) { Debug.Assert(res != null); //Debug.Assert(this method can only be called on the request thread) return StaticInfo.Get.Resources.AddFirst(new WeakReference(res)); }
internal static PhpSqlDbProcedure ValidProcedure(PhpResource handle) { PhpSqlDbProcedure result = handle as PhpSqlDbProcedure; if (result != null && result.IsValid) return result; PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_stored_procedure_resource")); return null; }
internal static PhpSqlDbResult ValidResult(PhpResource handle) { PhpSqlDbResult result = handle as PhpSqlDbResult; if (result != null && result.IsValid) return result; PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_result_resource")); return null; }
public static void Close(PhpResource linkIdentifier) { PhpSQLiteDbConnection connection = PhpSQLiteDbConnection.ValidConnection(linkIdentifier); if (connection != null) { connection.Close(); } }
/// <summary> /// Validates whether the specified handler is instance of PhpDbConnection type. /// </summary> /// <param name="handle"></param> /// <returns></returns> internal static PhpSqlDbConnection ValidConnection(PhpResource handle) { PhpSqlDbConnection connection = handle as PhpSqlDbConnection; if (connection != null && connection.IsValid) return connection; PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_connection_resource")); return null; }
public static void Close(PhpResource ch) { PhpCurlResource curlHandle = ch as PhpCurlResource; if (curlHandle == null) return; curlHandle.Close(); }
/// <summary> /// Registers a resource that should be disposed of when the request is over. /// </summary> /// <param name="res">The resource.</param> internal LinkedListNode<PhpResource> RegisterResource(PhpResource/*!*/res) { Debug.Assert(res != null); if (resources == null) resources = new LinkedList<PhpResource>(); return resources.AddFirst(res); }
/// <summary> /// Registers a resource that should be disposed of when the request is over. /// </summary> /// <param name="res">The resource.</param> internal static LinkedListNode<PhpResource> RegisterResource(PhpResource/*!*/res) { Debug.Assert(res != null); //Debug.Assert(this method can only be called on the request thread) if (resources == null) resources = new LinkedList<PhpResource>(); return resources.AddFirst(res); }
public static object Errno(PhpResource ch) { //PhpException.FunctionNotSupported(PhpError.Warning); PhpCurlResource curlHandle = ch as PhpCurlResource; if (curlHandle == null) return null; return (int)curlHandle.ErrorCode; }
public object __construct(ScriptContext context, object argFileName, object argMode, object error) { string filename = PHP.Core.Convert.ObjectToString(argFileName); int mode = PHP.Core.Convert.ObjectToInteger(argMode); if (mode == 0) { mode = SQLite.DEFAULT_FILE_MODE; } this.m_filename = filename; this.m_con = SQLite.Open(this.m_filename, mode, error as PhpReference); return null; }
internal static PhpProcessHandle Validate(PhpResource resource) { PhpProcessHandle result = resource as PhpProcessHandle; if (result == null || !result.IsValid) { PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_process_resource")); return null; } return result; }
internal static PhpSQLiteDbConnection ValidConnection(PhpResource handle) { PhpSQLiteDbConnection connection; if (handle != null && handle.GetType() == typeof(PhpSQLiteDbConnection)) connection = (PhpSQLiteDbConnection)handle; else connection = null; if (connection != null && connection.IsValid) return connection; PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_connection_resource")); return null; }
public static string ReceiveFrom(PhpResource socket, int length, SendReceiveOptions flags, out string address) { address = null; SocketStream stream = SocketStream.GetValid(socket); if (stream == null) return null; PhpException.FunctionNotSupported(); return null; }
public static string ReceiveFrom(PhpResource socket, int length, SendReceiveOptions flags) { string address; return ReceiveFrom(socket, length, flags, out address); }
public static bool Accept(PhpResource serverSocket, int timeout, out string peerName) { peerName = ""; SocketStream stream = SocketStream.GetValid(serverSocket); if (stream == null) return false; PhpException.FunctionNotSupported(); return false; }
public static bool Accept(PhpResource serverSocket, int timeout) { string peerName; return Accept(serverSocket, timeout, out peerName); }
public static bool Accept(PhpResource serverSocket) { string peerName; return Accept(serverSocket, Configuration.Local.FileSystem.DefaultSocketTimeout, out peerName); }
public static PhpResource ConnectServer(string localSocket, out int errno, out string errstr, double timeout, SocketOptions flags, PhpResource context) { StreamContext sc = StreamContext.GetValid(context); if (sc == null) { errno = -1; errstr = null; return null; } int port; SplitSocketAddressPort(ref localSocket, out port); return Connect(localSocket, port, out errno, out errstr, timeout, flags, sc); }
public static string SocketGetName(PhpResource handle, bool wantPeer) { PhpException.FunctionNotSupported(); return null; }
public static void SetStreamContexts(PhpResource streams_context) { }
public static bool SetBlocking(PhpResource stream, int mode) { return PhpStreams.SetBlocking(stream, mode); }
internal static XmlParserResource ValidResource(PhpResource handle) { if (handle != null && handle.GetType() == typeof(XmlParserResource)) return (XmlParserResource)handle; PhpException.Throw(PhpError.Warning, Strings.invalid_xmlresource); return null; }
public static int SendTo(PhpResource socket, string data, SendReceiveOptions flags) { return SendTo(socket, data, flags, null); }
public static int SendTo(PhpResource socket, string data, SendReceiveOptions flags, string address) { SocketStream stream = SocketStream.GetValid(socket); if (stream == null) return -1; PhpException.FunctionNotSupported(); return -1; }
private static bool CopyImageTransparent(PhpResource dst_im, PhpResource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h, int pct) { PhpGdImageResource dst_img = PhpGdImageResource.ValidImage(dst_im); if (dst_img == null) return false; PhpGdImageResource src_img = PhpGdImageResource.ValidImage(src_im); if (src_img == null) return false; if (pct <= 0 || src_w <= 0 || src_h <= 0) return true; ImageAttributes ia = null; if (pct < 100) { // prepare transformation matrix if needed ColorMatrix cm = new ColorMatrix(); cm.Matrix00 = cm.Matrix11 = cm.Matrix22 = cm.Matrix44 = 1.0f; cm.Matrix33 = (float)pct * 0.01f; ia = new ImageAttributes(); ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); } try { // draw the image using (Graphics g = Graphics.FromImage(dst_img.Image)) { g.DrawImage(src_img.Image, new Rectangle(dst_x, dst_y, src_w, src_h), src_x, src_y, src_w, src_h, GraphicsUnit.Pixel, ia); } } catch (Exception ex) { // output the warning PhpException.Throw(PhpError.Warning, ex.Message); return false; } finally { if (ia != null) { ia.Dispose(); ia = null; } } return true; }
public static PhpArray GetStatus(PhpResource stream) { return PhpStreams.GetMetaData(stream); }
public static bool imagecopymergegray(PhpResource src_im, PhpResource dst_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h, int pct) { //PhpException.FunctionNotSupported(PhpError.Warning); return false; }
public static bool SetTimeout(PhpResource stream, int seconds, int microseconds) { return PhpStreams.SetTimeout(stream, seconds, microseconds); }
public static bool imagecopyresampled(PhpResource dst_im, PhpResource src_im, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h) { return ImageCopyAndResize(dst_im, src_im, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h, InterpolationMode.HighQualityBicubic); }
new public static SocketStream GetValid(PhpResource handle) { SocketStream result = handle as SocketStream; if (result == null) PhpException.Throw(PhpError.Warning, CoreResources.GetString("invalid_socket_stream_resource")); return result; }
/// <summary> /// Create a new instance of a given Type and Name. /// The instance Id is auto-incrementing starting from 1. /// </summary> /// <param name="resourceTypeName">The type to be reported to use when dumping a resource.</param> /// <param name="registerInReqContext">Whether to register this instance in current <see cref="RequestContext"/>. Should be <c>false</c> for static resources.</param> public PhpResource(String resourceTypeName, bool registerInReqContext) : this(PhpResource.RegisterInternalInstance(), resourceTypeName, registerInReqContext) { }