Esempio n. 1
0
        /// <summary>
        /// Implements the interfaces and any of their descendent interfaces.
        /// </summary>
        /// <param name="typeBuilder">A type builder.</param>
        /// <param name="interfaceTypes">The interface type.</param>
        /// <returns>The type builder.</returns>
        public static ITypeBuilder ImplementsInterfaces(this ITypeBuilder typeBuilder, params Type[] interfaceTypes)
        {
            foreach (var interfaceType in interfaceTypes)
            {
                typeBuilder.Implements(interfaceType);

                Type[] baseTypes = interfaceType.GetInterfaces();
                if (baseTypes.IsNullOrEmpty() == false)
                {
                    typeBuilder.ImplementsInterfaces(baseTypes);
                }
            }

            return(typeBuilder);
        }
Esempio n. 2
0
        /// <summary>
        /// Implements the interface and any of it descendent interfaces.
        /// </summary>
        /// <param name="typeBuilder">A type builder.</param>
        /// <param name="interfaceType">The interface type.</param>
        /// <returns>The type builder.</returns>
        public static ITypeBuilder ImplementsInterfaces(this ITypeBuilder typeBuilder, Type interfaceType)
        {
            typeBuilder.Implements(interfaceType);

            Type[] implementedInterfaces = interfaceType.GetInterfaces();
            if (implementedInterfaces.IsNullOrEmpty() == false)
            {
                foreach (Type type in implementedInterfaces)
                {
                    typeBuilder.ImplementsInterfaces(type);
                }
            }

            return(typeBuilder);
        }