C# Class Pchp.Core.PhpResource

Base class for PHP Resources - both built-in and extension-resources. Resources rely on GC Finalization - override FreeManaged for cleanup. When printing a resource variable in PHP, "Resource id #x" prints out.
Inheritance: IDisposable, IPhpConvertible
Mostra file Open project: iolevel/peachpie Class Usage Examples

Protected Properties

Property Type Description
_resourceId int
_typeName string

Private Properties

Property Type Description
IPhpConvertible Convert.NumberInfo
IPhpConvertible bool
IPhpConvertible double
IPhpConvertible long
IPhpConvertible object
IPhpConvertible string
PhpResource Pchp.Core
RegisterInternalInstance int

Public Methods

Method Description
Dispose ( ) : void

Disposes the resource.

Dispose ( bool disposing ) : void

Cleans-up the resource.

When disposing non-deterministically, only unmanaged resources should be freed. FreeUnmanaged

PhpResource ( string resourceTypeName ) : Pchp.Core

Create a new instance of a given Type and Name. The instance Id is auto-incrementing starting from 1.

ToString ( ) : string

Returns a string that represents the current PhpResource.

Protected Methods

Method Description
FreeManaged ( ) : void

Override this virtual method in your descendants to perform cleanup of Managed resources - those having a Finalizer of their own.

Note that when Disposing explicitly, both FreeManaged and FreeUnmanaged are called.

FreeUnmanaged ( ) : void

Override this virtual method to cleanup the contained unmanaged objects.

Note that when Dispose(false) is called from the Finalizer, the order of finalization is random. In other words, contained managed objects may have been already finalized - don't reference them.

PhpResource ( int resourceId, string resourceTypeName ) : Pchp.Core

Create a new instance with the given Id.

Private Methods

Method Description
IPhpConvertible ( PhpNumber &number ) : Convert.NumberInfo
IPhpConvertible ( ) : bool
IPhpConvertible ( ) : double
IPhpConvertible ( ) : long
IPhpConvertible ( ) : object
IPhpConvertible ( Context ctx ) : string
PhpResource ( ) : Pchp.Core

Creates a new invalid resource.

RegisterInternalInstance ( ) : int

Allocate a unique identifier for a resource.

Internal resources are given even numbers while resources allocated by extensions get odd numbers to minimize the communication between internal and external resource managers.

Method Details

Dispose() public method

Disposes the resource.
public Dispose ( ) : void
return void

Dispose() public method

Cleans-up the resource.
When disposing non-deterministically, only unmanaged resources should be freed. FreeUnmanaged
public Dispose ( bool disposing ) : void
disposing bool Whether the resource is disposed deterministically.
return void

FreeManaged() protected method

Override this virtual method in your descendants to perform cleanup of Managed resources - those having a Finalizer of their own.
Note that when Disposing explicitly, both FreeManaged and FreeUnmanaged are called.
protected FreeManaged ( ) : void
return void

FreeUnmanaged() protected method

Override this virtual method to cleanup the contained unmanaged objects.
Note that when Dispose(false) is called from the Finalizer, the order of finalization is random. In other words, contained managed objects may have been already finalized - don't reference them.
protected FreeUnmanaged ( ) : void
return void

PhpResource() protected method

Create a new instance with the given Id.
protected PhpResource ( int resourceId, string resourceTypeName ) : Pchp.Core
resourceId int Unique resource identifier (odd for external resources).
resourceTypeName string The type to be reported to use when dumping a resource.
return Pchp.Core

PhpResource() public method

Create a new instance of a given Type and Name. The instance Id is auto-incrementing starting from 1.
public PhpResource ( string resourceTypeName ) : Pchp.Core
resourceTypeName string The type to be reported to use when dumping a resource.
return Pchp.Core

ToString() public method

Returns a string that represents the current PhpResource.
public ToString ( ) : string
return string

Property Details

_resourceId protected_oe property

Unique resource identifier (even for internal resources, odd for external ones).
Internal resources are given even numbers while resources allocated by extensions get odd numbers to minimize the communication between internal and external resource managers.
protected int _resourceId
return int

_typeName protected_oe property

Type resource name - string to be reported to user when dumping a resource.
protected string _typeName
return string