Exemplo n.º 1
0
        /// <summary>
        /// Registers a type for serialization with the specified class alias.
        /// </summary>
        /// <remarks>
        /// This method is equivalent to calling <see cref="ActionScriptMappingReflector.CreateClassMapping" />
        /// followed by <see cref="RegisterClassMapping" />.
        /// It serves a similar purpose to the "flex.net.registerClassAlias" method on the client side.
        /// </remarks>
        /// <param name="nativeType">The native type</param>
        /// <param name="classAliasOverride">The ActionScript class alias</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="nativeType"/> is null</exception>
        /// <exception cref="ActionScriptException">Thrown if the mapped native type
        /// or the class alias have already been registered with different mappings</exception>
        /// <exception cref="ActionScriptException">Thrown when an error occurs generating the class mapping</exception>
        public void RegisterType(Type nativeType, string classAliasOverride)
        {
            if (nativeType == null)
            {
                throw new ArgumentNullException("nativeType");
            }

            ActionScriptClassMapping classMapping = ActionScriptMappingReflector.CreateClassMapping(nativeType, classAliasOverride);

            RegisterClassMapping(classMapping);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Registers all ActionScript serializable types within the specified
        /// assembly with the mapper.
        /// </summary>
        /// <remarks>
        /// This method is equivalent to calling <see cref="RegisterType(Type)" />
        /// for each public <see cref="Type" /> in the <paramref name="assembly" /> that is
        /// decorated with <see cref="ActionScriptClassAttribute" />.
        /// </remarks>
        /// <param name="assembly">The assembly to search for serializable types</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="assembly"/> is null</exception>
        /// <exception cref="ActionScriptException">Thrown if any of the mapped native types
        /// or their ActionScript aliases have already been registered with different mappings</exception>
        /// <exception cref="ActionScriptException">Thrown when an error occurs generating a class mapping</exception>
        public void RegisterTypesInAssembly(Assembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            foreach (ActionScriptClassMapping classMapping in ActionScriptMappingReflector.GetClassMappingsForTypesInAssembly(assembly))
            {
                RegisterClassMapping(classMapping);
            }
        }