Class UserData
Class exposing C# objects as Lua userdata. For efficiency, a global registry of types is maintained, instead of a per-script one.
Inherited Members
Namespace: System.Dynamic.ExpandoObject
Assembly: cs.temp.dll.dll
Syntax
public class UserData : RefIdObject
Properties
DefaultAccessMode
Gets or sets the default access mode to be used in the whole application
Declaration
public static InteropAccessMode DefaultAccessMode { get; set; }
Property Value
InteropAccessMode
The default access mode. |
Exceptions
System.ArgumentException
InteropAccessMode is InteropAccessMode.Default |
Descriptor
Gets the type descriptor of this userdata
Declaration
public IUserDataDescriptor Descriptor { get; }
Property Value
IUserDataDescriptor
|
Object
Gets the object associated to this userdata (null for statics)
Declaration
public object Object { get; }
Property Value
System.Object
|
RegistrationPolicy
Gets or sets the registration policy to be used in the whole application
Declaration
public static IRegistrationPolicy RegistrationPolicy { get; set; }
Property Value
IRegistrationPolicy
|
UserValue
Gets or sets the "uservalue". See debug.getuservalue and debug.setuservalue. http://www.lua.org/manual/5.2/manual.html#pdf-debug.setuservalue
Declaration
public DynValue UserValue { get; set; }
Property Value
DynValue
|
Methods
Create(Object)
Creates a userdata DynValue from the specified object
Declaration
public static DynValue Create(object o)
Parameters
System.Object
o
The object |
Returns
DynValue
|
Create(Object, IUserDataDescriptor)
Creates a userdata DynValue from the specified object, using a specific descriptor
Declaration
public static DynValue Create(object o, IUserDataDescriptor descr)
Parameters
System.Object
o
The object |
IUserDataDescriptor
descr
The descriptor. |
Returns
DynValue
|
CreateStatic(IUserDataDescriptor)
Creates a static userdata DynValue from the specified IUserDataDescriptor
Declaration
public static DynValue CreateStatic(IUserDataDescriptor descr)
Parameters
IUserDataDescriptor
descr
The IUserDataDescriptor |
Returns
DynValue
|
CreateStatic(Type)
Creates a static userdata DynValue from the specified Type
Declaration
public static DynValue CreateStatic(Type t)
Parameters
Type
t
The type |
Returns
DynValue
|
CreateStatic<T>()
Creates a static userdata DynValue from the specified Type
Declaration
public static DynValue CreateStatic<T>()
Returns
DynValue
|
Type Parameters
T
The Type |
GetDescriptionOfRegisteredTypes(Boolean)
Gets a table with the description of registered types.
Declaration
public static Table GetDescriptionOfRegisteredTypes(bool useHistoricalData = false)
Parameters
System.Boolean
useHistoricalData
if set to true, it will also include the last found descriptor of all unregistered types. |
Returns
Table
|
GetDescriptorForObject(Object)
Gets the best possible type descriptor for a specified CLR object.
Declaration
public static IUserDataDescriptor GetDescriptorForObject(object o)
Parameters
System.Object
o
The object. |
Returns
IUserDataDescriptor
|
GetDescriptorForType(Type, Boolean)
Gets the best possible type descriptor for a specified CLR type.
Declaration
public static IUserDataDescriptor GetDescriptorForType(Type type, bool searchInterfaces)
Parameters
Type
type
The CLR type for which the descriptor is desired. |
System.Boolean
searchInterfaces
if set to |
Returns
IUserDataDescriptor
|
GetDescriptorForType<T>(Boolean)
Gets the best possible type descriptor for a specified CLR type.
Declaration
public static IUserDataDescriptor GetDescriptorForType<T>(bool searchInterfaces)
Parameters
System.Boolean
searchInterfaces
if set to |
Returns
IUserDataDescriptor
|
Type Parameters
T
The CLR type for which the descriptor is desired. |
GetExtensionMethodsByNameAndType(String, Type)
Gets all the extension methods which can match a given name and extending a given Type
Declaration
public static List<IOverloadableMemberDescriptor> GetExtensionMethodsByNameAndType(string name, Type extendedType)
Parameters
System.String
name
The name. |
Type
extendedType
The extended type. |
Returns
List<IOverloadableMemberDescriptor>
|
GetExtensionMethodsChangeVersion()
Gets a number which gets incremented everytime the extension methods registry changes. Use this to invalidate caches based on extension methods
Declaration
public static int GetExtensionMethodsChangeVersion()
Returns
System.Int32
|
GetRegisteredTypes(Boolean)
Gets all the registered types.
Declaration
public static IEnumerable<Type> GetRegisteredTypes(bool useHistoricalData = false)
Parameters
System.Boolean
useHistoricalData
if set to true, it will also include the last found descriptor of all unregistered types. |
Returns
IEnumerable<Type>
|
IsTypeRegistered(Type)
Determines whether the specified type is registered. Note that this should be used only to check if a descriptor has been registered EXACTLY. For many types a descriptor can still be created, for example through the descriptor of a base type or implemented interfaces.
Declaration
public static bool IsTypeRegistered(Type t)
Parameters
Type
t
The type. |
Returns
System.Boolean
|
IsTypeRegistered<T>()
Determines whether the specified type is registered. Note that this should be used only to check if a descriptor has been registered EXACTLY. For many types a descriptor can still be created, for example through the descriptor of a base type or implemented interfaces.
Declaration
public static bool IsTypeRegistered<T>()
Returns
System.Boolean
|
Type Parameters
T
The type. |
RegisterAssembly(Assembly, Boolean)
Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly.
Declaration
public static void RegisterAssembly(Assembly asm = null, bool includeExtensionTypes = false)
Parameters
Assembly
asm
The assembly. |
System.Boolean
includeExtensionTypes
if set to |
RegisterExtensionType(Type, InteropAccessMode)
Registers an extension Type (that is a type containing extension methods)
Declaration
public static void RegisterExtensionType(Type type, InteropAccessMode mode = InteropAccessMode.Default)
Parameters
Type
type
The type. |
InteropAccessMode
mode
The InteropAccessMode. |
RegisterProxyType(IProxyFactory, InteropAccessMode, String)
Registers a proxy type.
Declaration
public static IUserDataDescriptor RegisterProxyType(IProxyFactory proxyFactory, InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null)
Parameters
IProxyFactory
proxyFactory
The proxy factory. |
InteropAccessMode
accessMode
The access mode. |
System.String
friendlyName
A friendly name for the descriptor. |
Returns
IUserDataDescriptor
|
RegisterProxyType<TProxy, TTarget>(Func<TTarget, TProxy>, InteropAccessMode, String)
Registers a proxy type using a delegate.
Declaration
public static IUserDataDescriptor RegisterProxyType<TProxy, TTarget>(Func<TTarget, TProxy> wrapDelegate, InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null)where TProxy : class where TTarget : class
Parameters
Func<TTarget, TProxy>
wrapDelegate
A delegate creating a proxy object from a target object. |
InteropAccessMode
accessMode
The access mode. |
System.String
friendlyName
A friendly name for the descriptor. |
Returns
IUserDataDescriptor
|
Type Parameters
TProxy
The type of the proxy. |
TTarget
The type of the target. |
RegisterType(IUserDataDescriptor)
Registers a type with a custom userdata descriptor
Declaration
public static IUserDataDescriptor RegisterType(IUserDataDescriptor customDescriptor)
Parameters
IUserDataDescriptor
customDescriptor
The custom descriptor. |
Returns
IUserDataDescriptor
|
RegisterType(Type, InteropAccessMode, String)
Registers a type for userdata interop
Declaration
public static IUserDataDescriptor RegisterType(Type type, InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null)
Parameters
Type
type
The type to be registered |
InteropAccessMode
accessMode
The access mode (optional). |
System.String
friendlyName
Friendly name for the type (optional) |
Returns
IUserDataDescriptor
|
RegisterType(Type, IUserDataDescriptor)
Registers a type with a custom userdata descriptor
Declaration
public static IUserDataDescriptor RegisterType(Type type, IUserDataDescriptor customDescriptor)
Parameters
Type
type
The type to be registered |
IUserDataDescriptor
customDescriptor
The custom descriptor. |
Returns
IUserDataDescriptor
|
RegisterType<T>(InteropAccessMode, String)
Registers a type for userdata interop
Declaration
public static IUserDataDescriptor RegisterType<T>(InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null)
Parameters
InteropAccessMode
accessMode
The access mode (optional). |
System.String
friendlyName
Friendly name for the type (optional) |
Returns
IUserDataDescriptor
|
Type Parameters
T
The type to be registered |
RegisterType<T>(IUserDataDescriptor)
Registers a type with a custom userdata descriptor
Declaration
public static IUserDataDescriptor RegisterType<T>(IUserDataDescriptor customDescriptor)
Parameters
IUserDataDescriptor
customDescriptor
The custom descriptor. |
Returns
IUserDataDescriptor
|
Type Parameters
T
The type to be registered |
UnregisterType(Type)
Unregisters a type. WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. Use this only for testing purposes or to re-register the same type in a slightly different way. Additionally, it's a good practice to discard all previous loaded scripts after calling this method.
Declaration
public static void UnregisterType(Type t)
Parameters
Type
t
The The type to be unregistered |
UnregisterType<T>()
Unregisters a type. WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. Use this only for testing purposes or to re-register the same type in a slightly different way. Additionally, it's a good practice to discard all previous loaded scripts after calling this method.
Declaration
public static void UnregisterType<T>()
Type Parameters
T
The type to be unregistered |