예제 #1
0
        internal CollectionElementToken(QueryToken parent, CollectionElementType type)
            : base(parent)
        {
            elementType = parent.Type.ElementType();
            if (elementType == null)
                throw new InvalidOperationException("not a collection");

            this.CollectionElementType = type;
        }
예제 #2
0
    internal CollectionElementToken(QueryToken parent, CollectionElementType type)
    {
        elementType = parent.Type.ElementType() !;
        if (elementType == null)
        {
            throw new InvalidOperationException("not a collection");
        }

        this.parent = parent ?? throw new ArgumentNullException(nameof(parent));
        this.CollectionElementType = type;
    }
예제 #3
0
        internal CollectionElementToken(QueryToken parent, CollectionElementType type)
            : base(parent)
        {
            elementType = parent.Type.ElementType();
            if (elementType == null)
            {
                throw new InvalidOperationException("not a collection");
            }

            this.CollectionElementType = type;
        }
예제 #4
0
        public override string NiceName()
        {
            if (!CollectionElementType.IsElement())
            {
                throw new InvalidOperationException("NiceName not supported for {0}".FormatWith(CollectionElementType));
            }

            Type parentElement = elementType.CleanType();

            if (parentElement.IsModifiableEntity())
            {
                return(parentElement.NiceName());
            }

            return("Element of " + Parent.NiceName());
        }
예제 #5
0
        public override string NiceName()
        {
            if (!CollectionElementType.IsElement())
            {
                return(null);
            }

            Type parentElement = elementType.CleanType();

            if (parentElement.IsModifiableEntity())
            {
                return(parentElement.NiceName());
            }

            return("Element of " + Parent.NiceName());
        }
예제 #6
0
            public CollectionsQueryModelParameterDetails(Type parameterType)
            {
                IsArray = parameterType.IsArray;
                var info = parameterType.GetTypeInfo();

                if (IsArray)
                {
                    CollectionElementType = parameterType.GetElementType();
                }
                else
                {
                    IsList = info.IsGenericType && info.GetGenericTypeDefinition() == typeof(List <>);
                    if (IsList)
                    {
                        CollectionElementType = info.GenericTypeArguments.Single();
                    }
                }
                if (!IsArray && !IsList)
                {
                    IsIEnumerable = info.IsGenericType && info.GetGenericTypeDefinition() == typeof(IEnumerable <>);
                    if (IsIEnumerable)
                    {
                        CollectionElementType = info.GenericTypeArguments.Single();
                    }
                }

                if (IsArray || IsList || IsIEnumerable)
                {
                    OriginalCollectionElementType = CollectionElementType;
                    Type nullableArgument;
                    if (CollectionElementType.GetTypeInfo().IsNullable(out nullableArgument))
                    {
                        IsCollectionElementTypeNullable = true;
                        CollectionElementType           = nullableArgument;
                    }
                }
            }
예제 #7
0
 public override string ToString()
 {
     return(CollectionElementType.NiceToString());
 }
예제 #8
0
 public static bool IsElement(this CollectionElementType cet)
 {
     return(cet == CollectionElementType.Element ||
            cet == CollectionElementType.Element2 ||
            cet == CollectionElementType.Element3);
 }