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
Afficher le fichier Open project: iolevel/peachpie Class Usage Examples

Protected Properties

Свойство Type Description
_resourceId int
_typeName string

Private Properties

Свойство Type Description
IPhpConvertible Convert.NumberInfo
IPhpConvertible bool
IPhpConvertible double
IPhpConvertible long
IPhpConvertible object
IPhpConvertible string
PhpResource Pchp.Core
RegisterInternalInstance int

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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

Méthode 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 méthode

Disposes the resource.
public Dispose ( ) : void
Résultat void

Dispose() public méthode

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.
Résultat void

FreeManaged() protected méthode

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
Résultat void

FreeUnmanaged() protected méthode

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
Résultat void

PhpResource() protected méthode

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.
Résultat Pchp.Core

PhpResource() public méthode

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.
Résultat Pchp.Core

ToString() public méthode

Returns a string that represents the current PhpResource.
public ToString ( ) : string
Résultat 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
Résultat int

_typeName protected_oe property

Type resource name - string to be reported to user when dumping a resource.
protected string _typeName
Résultat string