Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 /// <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));
 }
Ejemplo n.º 4
0
 /// <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));
 }
Ejemplo n.º 5
0
 /// <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));
 }
Ejemplo n.º 6
0
 /// <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));
 }
Ejemplo n.º 7
0
 /// <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);
 }
Ejemplo n.º 8
0
 /// <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));
 }
Ejemplo n.º 9
0
 /// <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)));
 }
Ejemplo n.º 10
0
 /// <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));
 }
Ejemplo n.º 11
0
 /// <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));
 }
Ejemplo n.º 12
0
 /// <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);
 }
Ejemplo n.º 13
0
		/// <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);
		}
Ejemplo n.º 14
0
		/// <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);
		}
Ejemplo n.º 15
0
 /// <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));
 }