C# 클래스 V8.Net.V8NativeObject

Represents a basic JavaScript object. This class wraps V8 functionality for operations required on any native V8 object (including managed ones).

This class implements 'DynamicObject' to make setting properties a bit easier.

상속: IHandleBased, IV8Object, IV8NativeObject, IDynamicMetaObjectProvider, IFinalizable
파일 보기 프로젝트 열기: rjamesnw/v8dotnet 1 사용 예제들

Private Properties

프로퍼티 타입 설명
IFinalizable void
_MakeWeak void
_OnNativeGCRequested bool
_TryDisposeNativeHandle void

공개 메소드들

메소드 설명
AsHandle ( ) : Handle
Call ( InternalHandle _this ) : InternalHandle

Calls the underlying object as a function. The '_this' parameter is the "this" reference within the function when called.

Call ( string functionName, InternalHandle _this ) : InternalHandle

Calls an object property with a given name on a specified object as a function and returns the result. The '_this' property is the "this" object within the function when called.

DeleteProperty ( Int32 index ) : bool

Calls the V8 'Delete()' function on the underlying native object. Returns true if the property was deleted.

DeleteProperty ( string name ) : bool

Calls the V8 'Delete()' function on the underlying native object. Returns true if the property was deleted.

Dispose ( ) : void

Called when there are no more references (on either the managed or native side) and the object is ready to be deleted from the V8.NET system. You should never call this from code directly unless you need to force the release of native resources associated with a custom implementation (and if so, a custom internal flag should be kept indicating whether or not the resources have been disposed). You should always override/implement this if you need to dispose of any native resources in custom implementations. DO NOT rely on the destructor (finalizer) - the object can still survive it.

Note: This can be triggered either by the worker thread, or on the call-back from the V8 garbage collector. In either case, tread it as if it was called from the GC finalizer (not on the main thread).

*** If overriding, DON'T call back to this method, otherwise it will call back and end up in a cyclical call (and a stack overflow!). ***

GetMetaObject ( Expression parameter ) : DynamicMetaObject
GetOwnPropertyNames ( ) : string[]

Returns a list of all property names for this object (excluding the prototype chain).

GetProperty ( Int32 index ) : InternalHandle

Calls the V8 'Get()' function on the underlying native object. If the property doesn't exist, the 'IsUndefined' property will be true.

GetProperty ( string name ) : InternalHandle

Calls the V8 'Get()' function on the underlying native object. If the property doesn't exist, the 'IsUndefined' property will be true.

GetPropertyAttributes ( string name ) : V8PropertyAttributes

Get the attribute flags for a property of this object. If a property doesn't exist, then 'V8PropertyAttributes.None' is returned (Note: only V8 returns 'None'. The value 'Undefined' has an internal proxy meaning for property interception).

GetPropertyNames ( ) : string[]

Returns a list of all property names for this object (including all objects in the prototype chain).

Initialize ( bool isConstructCall ) : ObjectHandle

Called immediately after creating an object instance and setting the V8Engine property. Derived objects should override this for construction instead of using the constructor, and be sure to call back to this base method just before exiting (not at the beginning). In the constructor, the object only exists as an empty shell. It's ok to setup non-v8 values in constructors, but be careful not to trigger any calls into the V8Engine itself.

Note: Because this method is virtual, it does not guarantee that 'IsInitialized' will be considered. Implementations should check against the 'IsInitilized' property.

Initialize ( V8NativeObject owner, bool isConstructCall ) : void

(Exists only to support the 'IV8NativeInterface' interface and should not be called directly - call 'Initialize(isConstructCall, args)' instead.)

SetAccessor ( string name, V8NativeObjectPropertyGetter getter, V8NativeObjectPropertySetter setter, V8PropertyAttributes attributes = V8PropertyAttributes.None, V8AccessControl access = V8AccessControl.Default ) : void

Calls the V8 'SetAccessor()' function on the underlying native object to create a property that is controlled by "getter" and "setter" callbacks.

SetProperty ( Int32 index, InternalHandle value ) : bool

Calls the V8 'Set()' function on the underlying native object. Returns true if successful.

SetProperty ( Type type, V8PropertyAttributes propertyAttributes = V8PropertyAttributes.None, string className = null, bool recursive = null, ScriptMemberSecurity memberSecurity = null ) : bool

Binds a 'V8Function' object to the specified type and associates the type name (or custom script name) with the underlying object. Returns true if successful.

SetProperty ( string name, InternalHandle value, V8PropertyAttributes attributes = V8PropertyAttributes.None ) : bool

Calls the V8 'Set()' function on the underlying native object. Returns true if successful.

SetProperty ( string name, object obj, string className = null, bool recursive = null, ScriptMemberSecurity memberSecurity = null ) : bool

Sets a property to a given object. If the object is not V8.NET related, then the system will attempt to bind the instance and all public members to the specified property name. Returns true if successful.

StaticCall ( ) : InternalHandle

Calls the underlying object as a function. The 'this' property will not be specified, which will default to the global scope as expected.

StaticCall ( string functionName ) : InternalHandle

Calls an object property with a given name on a specified object as a function and returns the result.

ToString ( ) : string
V8NativeObject ( ) : System.Dynamic
V8NativeObject ( IV8NativeObject proxy ) : System.Dynamic
this ( int index ) : InternalHandle
this ( string propertyName ) : InternalHandle

비공개 메소드들

메소드 설명
IFinalizable ( ) : void
_MakeWeak ( ) : void

Called by the worker thread to make the native handle weak. Once the native GC attempts to collect the underlying native object, then '_OnNativeGCRequested()' will get called to finalize the disposal of the managed object.

_OnNativeGCRequested ( ) : bool
_TryDisposeNativeHandle ( ) : void

This is called automatically when both the handle AND reference for the managed object are weak [no longer in use], in which case this object info instance is ready to be removed.

메소드 상세

AsHandle() 공개 메소드

public AsHandle ( ) : Handle
리턴 Handle

Call() 공개 메소드

Calls the underlying object as a function. The '_this' parameter is the "this" reference within the function when called.
public Call ( InternalHandle _this ) : InternalHandle
_this InternalHandle
리턴 InternalHandle

Call() 공개 메소드

Calls an object property with a given name on a specified object as a function and returns the result. The '_this' property is the "this" object within the function when called.
public Call ( string functionName, InternalHandle _this ) : InternalHandle
functionName string
_this InternalHandle
리턴 InternalHandle

DeleteProperty() 공개 메소드

Calls the V8 'Delete()' function on the underlying native object. Returns true if the property was deleted.
public DeleteProperty ( Int32 index ) : bool
index System.Int32
리턴 bool

DeleteProperty() 공개 메소드

Calls the V8 'Delete()' function on the underlying native object. Returns true if the property was deleted.
public DeleteProperty ( string name ) : bool
name string
리턴 bool

Dispose() 공개 메소드

Called when there are no more references (on either the managed or native side) and the object is ready to be deleted from the V8.NET system. You should never call this from code directly unless you need to force the release of native resources associated with a custom implementation (and if so, a custom internal flag should be kept indicating whether or not the resources have been disposed). You should always override/implement this if you need to dispose of any native resources in custom implementations. DO NOT rely on the destructor (finalizer) - the object can still survive it.

Note: This can be triggered either by the worker thread, or on the call-back from the V8 garbage collector. In either case, tread it as if it was called from the GC finalizer (not on the main thread).

*** If overriding, DON'T call back to this method, otherwise it will call back and end up in a cyclical call (and a stack overflow!). ***
public Dispose ( ) : void
리턴 void

GetMetaObject() 공개 메소드

public GetMetaObject ( Expression parameter ) : DynamicMetaObject
parameter System.Linq.Expressions.Expression
리턴 System.Dynamic.DynamicMetaObject

GetOwnPropertyNames() 공개 메소드

Returns a list of all property names for this object (excluding the prototype chain).
public GetOwnPropertyNames ( ) : string[]
리턴 string[]

GetProperty() 공개 메소드

Calls the V8 'Get()' function on the underlying native object. If the property doesn't exist, the 'IsUndefined' property will be true.
public GetProperty ( Int32 index ) : InternalHandle
index System.Int32
리턴 InternalHandle

GetProperty() 공개 메소드

Calls the V8 'Get()' function on the underlying native object. If the property doesn't exist, the 'IsUndefined' property will be true.
public GetProperty ( string name ) : InternalHandle
name string
리턴 InternalHandle

GetPropertyAttributes() 공개 메소드

Get the attribute flags for a property of this object. If a property doesn't exist, then 'V8PropertyAttributes.None' is returned (Note: only V8 returns 'None'. The value 'Undefined' has an internal proxy meaning for property interception).

public GetPropertyAttributes ( string name ) : V8PropertyAttributes
name string
리턴 V8PropertyAttributes

GetPropertyNames() 공개 메소드

Returns a list of all property names for this object (including all objects in the prototype chain).
public GetPropertyNames ( ) : string[]
리턴 string[]

Initialize() 공개 메소드

Called immediately after creating an object instance and setting the V8Engine property. Derived objects should override this for construction instead of using the constructor, and be sure to call back to this base method just before exiting (not at the beginning). In the constructor, the object only exists as an empty shell. It's ok to setup non-v8 values in constructors, but be careful not to trigger any calls into the V8Engine itself.

Note: Because this method is virtual, it does not guarantee that 'IsInitialized' will be considered. Implementations should check against the 'IsInitilized' property.

public Initialize ( bool isConstructCall ) : ObjectHandle
isConstructCall bool
리턴 ObjectHandle

Initialize() 공개 메소드

(Exists only to support the 'IV8NativeInterface' interface and should not be called directly - call 'Initialize(isConstructCall, args)' instead.)
public Initialize ( V8NativeObject owner, bool isConstructCall ) : void
owner V8NativeObject
isConstructCall bool
리턴 void

SetAccessor() 공개 메소드

Calls the V8 'SetAccessor()' function on the underlying native object to create a property that is controlled by "getter" and "setter" callbacks.
public SetAccessor ( string name, V8NativeObjectPropertyGetter getter, V8NativeObjectPropertySetter setter, V8PropertyAttributes attributes = V8PropertyAttributes.None, V8AccessControl access = V8AccessControl.Default ) : void
name string
getter V8NativeObjectPropertyGetter
setter V8NativeObjectPropertySetter
attributes V8PropertyAttributes
access V8AccessControl
리턴 void

SetProperty() 공개 메소드

Calls the V8 'Set()' function on the underlying native object. Returns true if successful.
public SetProperty ( Int32 index, InternalHandle value ) : bool
index System.Int32
value InternalHandle
리턴 bool

SetProperty() 공개 메소드

Binds a 'V8Function' object to the specified type and associates the type name (or custom script name) with the underlying object. Returns true if successful.
public SetProperty ( Type type, V8PropertyAttributes propertyAttributes = V8PropertyAttributes.None, string className = null, bool recursive = null, ScriptMemberSecurity memberSecurity = null ) : bool
type System.Type The type to wrap.
propertyAttributes V8PropertyAttributes Flags that describe the property behavior. They must be 'OR'd together as needed.
className string A custom in-script function name for the specified type, or 'null' to use either the type name as is (the default) or any existing 'ScriptObject' attribute name.
recursive bool For object types, if true, then object reference members are included, otherwise only the object itself is bound and returned. /// For security reasons, public members that point to object instances will be ignored. This must be true to included those as well, effectively allowing /// in-script traversal of the object reference tree (so make sure this doesn't expose sensitive methods/properties/fields).
memberSecurity ScriptMemberSecurity For object instances, these are default flags that describe JavaScript properties for all object instance members that /// don't have any 'ScriptMember' attribute. The flags should be 'OR'd together as needed.
리턴 bool

SetProperty() 공개 메소드

Calls the V8 'Set()' function on the underlying native object. Returns true if successful.
public SetProperty ( string name, InternalHandle value, V8PropertyAttributes attributes = V8PropertyAttributes.None ) : bool
name string
value InternalHandle
attributes V8PropertyAttributes Flags that describe the property behavior. They must be 'OR'd together as needed.
리턴 bool

SetProperty() 공개 메소드

Sets a property to a given object. If the object is not V8.NET related, then the system will attempt to bind the instance and all public members to the specified property name. Returns true if successful.
public SetProperty ( string name, object obj, string className = null, bool recursive = null, ScriptMemberSecurity memberSecurity = null ) : bool
name string The property name.
obj object Some value or object instance. 'Engine.CreateValue()' will be used to convert value types.
className string A custom in-script function name for the specified object type, or 'null' to use either the type name as is (the default) or any existing 'ScriptObject' attribute name.
recursive bool For object instances, if true, then object reference members are included, otherwise only the object itself is bound and returned. /// For security reasons, public members that point to object instances will be ignored. This must be true to included those as well, effectively allowing /// in-script traversal of the object reference tree (so make sure this doesn't expose sensitive methods/properties/fields).
memberSecurity ScriptMemberSecurity For object instances, these are default flags that describe JavaScript properties for all object instance members that /// don't have any 'ScriptMember' attribute. The flags should be 'OR'd together as needed.
리턴 bool

StaticCall() 공개 메소드

Calls the underlying object as a function. The 'this' property will not be specified, which will default to the global scope as expected.
public StaticCall ( ) : InternalHandle
리턴 InternalHandle

StaticCall() 공개 메소드

Calls an object property with a given name on a specified object as a function and returns the result.
public StaticCall ( string functionName ) : InternalHandle
functionName string
리턴 InternalHandle

ToString() 공개 메소드

public ToString ( ) : string
리턴 string

V8NativeObject() 공개 메소드

public V8NativeObject ( ) : System.Dynamic
리턴 System.Dynamic

V8NativeObject() 공개 메소드

public V8NativeObject ( IV8NativeObject proxy ) : System.Dynamic
proxy IV8NativeObject
리턴 System.Dynamic

this() 공개 메소드

public this ( int index ) : InternalHandle
index int
리턴 InternalHandle

this() 공개 메소드

public this ( string propertyName ) : InternalHandle
propertyName string
리턴 InternalHandle