/// <summary> /// Unregister this instance of <see cref="PhpResource"/> from current <see cref="RequestContext"/>. /// </summary> private void UnregisterResource() { if (this.reqContextRegistrationNode != null) { PhpResourceManager.UnregisterResource(this.reqContextRegistrationNode); this.reqContextRegistrationNode = null; } }
/// <summary> /// Create a new instance with the given Id. Used by <see cref="PhpExternalResource"/>s. /// </summary> /// <param name="resourceId">Unique resource identifier (odd for external resources).</param> /// <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> protected PhpResource(int resourceId, String resourceTypeName, bool registerInReqContext) { this.mResourceId = resourceId; this.mTypeName = resourceTypeName; if (registerInReqContext) { // register this resource into PhpResourceManager, // so the resource will be automatically disposed at the request end. this.reqContextRegistrationNode = PhpResourceManager.RegisterResource(this); } }