Exemplo n.º 1
0
        public static string GetContentPropertyTypeName(Element e)
        {
            var prop = GetContentProperty(e);

            if (prop == null)
            {
                return(null);
            }

            var isEnumerable = ReflectionMethods.ImplementsIEnumerable(prop);

            if (!isEnumerable)
            {
                return(prop.PropertyType.FullName);
            }

            var typeArgs = prop
                           .PropertyType
                           .GenericTypeArguments
                           .Select(a => a.FullName)
                           .ToArray();

            if (typeArgs.Length == 0)
            {
                return(prop.PropertyType.FullName);
            }

            var arg = string.Join(",", typeArgs);

            return($"{typeof(IEnumerable).FullName}<{arg}>");
        }
Exemplo n.º 2
0
        public static bool IsCollectionOfViews(PropertyInfo prop)
        {
            var isEnumerable = ReflectionMethods.ImplementsIEnumerable(prop);

            if (!isEnumerable)
            {
                return(false);
            }

            var hasViewArg = prop
                             .PropertyType
                             .GenericTypeArguments
                             .Any(a => a.IsAssignableFrom(typeof(View)));

            return(hasViewArg);
        }