Class StandardGenericsUserDataDescriptor
Standard user data descriptor used to instantiate generics.
Inheritance
Inherited Members
Namespace: System.Dynamic.ExpandoObject
Assembly: cs.temp.dll.dll
Syntax
public class StandardGenericsUserDataDescriptor : IGeneratorUserDataDescriptor, IUserDataDescriptor
Constructors
StandardGenericsUserDataDescriptor(Type, InteropAccessMode)
Initializes a new instance of the StandardUserDataDescriptor class.
Declaration
public StandardGenericsUserDataDescriptor(Type type, InteropAccessMode accessMode)
Parameters
|
Type
type
The type this descriptor refers to. |
|
InteropAccessMode
accessMode
The interop access mode this descriptor uses for members access |
Properties
AccessMode
Gets the interop access mode this descriptor uses for members access
Declaration
public InteropAccessMode AccessMode { get; }
Property Value
|
InteropAccessMode
|
Name
Gets the name of the descriptor (usually, the name of the type described).
Declaration
public string Name { get; }
Property Value
|
System.String
|
Implements
Type
Gets the type this descriptor refers to
Declaration
public Type Type { get; }
Property Value
|
Type
|
Implements
Methods
AsString(Object)
Converts this userdata to string
Declaration
public string AsString(object obj)
Parameters
|
System.Object
obj
The object. |
Returns
|
System.String
|
Implements
Generate(Type)
Generates a new descriptor for the specified type.
The purpose is to allow a mechanism by which a type descriptor can replace itself with another descriptor for a specific type. For example, descriptors can be created on the fly to support generic types through this mechanism.
The return value should be: null - if this descriptor is simply skipped for the specified type this - acts as if the descriptor was a vanilla descriptor a new descriptor - if a new descriptor should be used in place of this one
It's recommended that instances of descriptors are cached for future references. One possible way, to do the caching is to have the generator register the descriptor through RegisterType(Type, InteropAccessMode, String). In that case, it should query whether the type is exactly registered, through IsTypeRegistered(Type)
NOTE-1 : the search for descriptors does NOT stop with the descriptor returned by this type, but other descriptors (e.g. for interfaces) might still be added.
NOTE-2 : the descriptor generation mechanism is not triggered on an exact match of types.
NOTE-3 : the method is called in the context of a lock over the descriptors registry so no unpredictable changes to the registry can come from other threads during the execution of this method. However this method should not take other locks, to avoid deadlocks.
Declaration
public IUserDataDescriptor Generate(Type type)
Parameters
|
Type
type
The type. |
Returns
|
IUserDataDescriptor
Null, this object instance or a new descriptor. |
Implements
Index(Script, Object, DynValue, Boolean)
Performs an "index" "get" operation.
Declaration
public DynValue Index(Script script, object obj, DynValue index, bool isDirectIndexing)
Parameters
|
Script
script
The script originating the request |
|
System.Object
obj
The object (null if a static request is done) |
|
DynValue
index
The index. |
|
System.Boolean
isDirectIndexing
If set to true, it's indexed with a name, if false it's indexed through brackets. |
Returns
|
DynValue
|
Implements
IsTypeCompatible(Type, Object)
Determines whether the specified object is compatible with the specified type. Unless a very specific behaviour is needed, the correct implementation is a simple " return type.IsInstanceOfType(obj); "
Declaration
public bool IsTypeCompatible(Type type, object obj)
Parameters
|
Type
type
The type. |
|
System.Object
obj
The object. |
Returns
|
System.Boolean
|
Implements
MetaIndex(Script, Object, String)
Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, it should return "null" (not a nil).
These standard metamethods can be supported (the return value should be a function accepting the classic parameters of the corresponding metamethod): __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, __pairs, __ipairs, __iterator, __call
These standard metamethods are supported through other calls for efficiency: __index, __newindex, __tostring
Declaration
public DynValue MetaIndex(Script script, object obj, string metaname)
Parameters
|
Script
script
The script originating the request |
|
System.Object
obj
The object (null if a static request is done) |
|
System.String
metaname
The name of the metamember. |
Returns
|
DynValue
|
Implements
SetIndex(Script, Object, DynValue, DynValue, Boolean)
Performs an "index" "set" operation.
Declaration
public bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool isDirectIndexing)
Parameters
|
Script
script
The script originating the request |
|
System.Object
obj
The object (null if a static request is done) |
|
DynValue
index
The index. |
|
DynValue
value
The value to be set |
|
System.Boolean
isDirectIndexing
If set to true, it's indexed with a name, if false it's indexed through brackets. |
Returns
|
System.Boolean
|