Ejemplo n.º 1
0
        /// <summary>
        /// Gets the content types which can be assigned to a type or else
        /// if the type is a container, the content types it can contain
        /// </summary>
        /// <param name="targetType">the type</param>
        /// <returns>list of types which can be assigned to / contained by a type</returns>
        public static List <Type> GetAssignableContentTypes(Collator coll, Type targetType)
        {
            List <Type> types = AllContentTypes.Where(t => targetType.IsAssignableFrom(t)).ToList();

            if (types.Count > 0)
            {
                return(types);
            }

            types = AllContentTypes.Where(t => coll.ContainerType(t) == targetType).ToList();
            if (types.Count > 0)
            {
                return(types);
            }

            throw new Exception("Type " + targetType.FullName + " cannot contain any content types, it may need to be registered in LyniconConfig");
        }