/// <summary> /// Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. /// </summary> /// <param name="asm">The assembly.</param> /// <param name="includeExtensionTypes">if set to <c>true</c> extension types are registered to the appropriate registry.</param> public static void RegisterAssembly(Assembly asm = null, bool includeExtensionTypes = false) { if (asm == null) { asm = Assembly.GetCallingAssembly(); } TypeDescriptorRegistry.RegisterAssembly(asm, includeExtensionTypes); }
/// <summary> /// Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. /// </summary> /// <param name="asm">The assembly.</param> /// <param name="includeExtensionTypes">if set to <c>true</c> extension types are registered to the appropriate registry.</param> public static void RegisterAssembly(Assembly asm = null, bool includeExtensionTypes = false) { if (asm == null) { #if NETFX_CORE || DOTNET_CORE throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); #else asm = Assembly.GetCallingAssembly(); #endif } TypeDescriptorRegistry.RegisterAssembly(asm, includeExtensionTypes); }
/// <summary> /// Registers a proxy type. /// </summary> /// <param name="proxyFactory">The proxy factory.</param> /// <param name="accessMode">The access mode.</param> /// <param name="friendlyName">A friendly name for the descriptor.</param> /// <returns></returns> public static IUserDataDescriptor RegisterProxyType(IProxyFactory proxyFactory, InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null) { return(TypeDescriptorRegistry.RegisterProxyType_Impl(proxyFactory, accessMode, friendlyName)); }
/// <summary> /// Registers a type for userdata interop /// </summary> /// <param name="type">The type to be registered</param> /// <param name="accessMode">The access mode (optional).</param> /// <param name="friendlyName">Friendly name for the type (optional)</param> public static IUserDataDescriptor RegisterType(Type type, InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null) { return(TypeDescriptorRegistry.RegisterType_Impl(type, accessMode, friendlyName, null)); }
/// <summary> /// Gets the best possible type descriptor for a specified CLR object. /// </summary> /// <param name="o">The object.</param> /// <returns></returns> public static IUserDataDescriptor GetDescriptorForObject(object o) { return(TypeDescriptorRegistry.GetDescriptorForType(o.GetType(), true)); }
/// <summary> /// Gets the best possible type descriptor for a specified CLR type. /// </summary> /// <param name="type">The CLR type for which the descriptor is desired.</param> /// <param name="searchInterfaces">if set to <c>true</c> interfaces are used in the search.</param> /// <returns></returns> public static IUserDataDescriptor GetDescriptorForType(Type type, bool searchInterfaces) { return(TypeDescriptorRegistry.GetDescriptorForType(type, searchInterfaces)); }
/// <summary> /// 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. /// </summary> /// <param name="t">The The type to be unregistered</param> public static void UnregisterType(Type t) { TypeDescriptorRegistry.UnregisterType(t); }
/// <summary> /// 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. /// </summary> /// <typeparam name="T">The type to be unregistered</typeparam> public static void UnregisterType <T>() { TypeDescriptorRegistry.UnregisterType(typeof(T)); }
/// <summary> /// 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. /// </summary> /// <typeparam name="T">The type.</typeparam> /// <returns></returns> public static bool IsTypeRegistered <T>() { return(TypeDescriptorRegistry.IsTypeRegistered(typeof(T))); }
/// <summary> /// 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. /// </summary> /// <param name="t">The type.</param> /// <returns></returns> public static bool IsTypeRegistered(Type t) { return(TypeDescriptorRegistry.IsTypeRegistered(t)); }
/// <summary> /// Registers a type with a custom userdata descriptor /// </summary> /// <param name="customDescriptor">The custom descriptor.</param> public static IUserDataDescriptor RegisterType(IUserDataDescriptor customDescriptor) { return(TypeDescriptorRegistry.RegisterType_Impl(customDescriptor.Type, InteropAccessMode.Default, null, customDescriptor)); }
/// <summary> /// Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. /// </summary> /// <param name="asm">The assembly.</param> /// <param name="includeExtensionTypes">if set to <c>true</c> extension types are registered to the appropriate registry.</param> public static void RegisterAssembly(Assembly asm = null, bool includeExtensionTypes = false) { TypeDescriptorRegistry.RegisterAssembly(asm, includeExtensionTypes); }
/// <summary> /// Gets the best possible type descriptor for a specified CLR type. /// </summary> /// <typeparam name="T">The CLR type for which the descriptor is desired.</typeparam> /// <param name="searchInterfaces">if set to <c>true</c> interfaces are used in the search.</param> /// <returns></returns> public static IUserDataDescriptor GetDescriptorForType<T>(bool searchInterfaces) { return TypeDescriptorRegistry.GetDescriptorForType(typeof(T), searchInterfaces); }
/// <summary> /// Registers a type with a custom userdata descriptor /// </summary> /// <typeparam name="T">The type to be registered</typeparam> /// <param name="customDescriptor">The custom descriptor.</param> public static IUserDataDescriptor RegisterType<T>(IUserDataDescriptor customDescriptor) { return TypeDescriptorRegistry.RegisterType_Impl(typeof(T), InteropAccessMode.Default, null, customDescriptor); }
/// <summary> /// Gets the best possible type descriptor for a specified CLR object. /// </summary> /// <param name="o">The object.</param> /// <returns></returns> public static IUserDataDescriptor GetDescriptorForObject <T>(T t) { return(TypeDescriptorRegistry.GetDescriptorForType(typeof(T).IsValueType ? typeof(T) : t.GetType(), true)); }