internal CollectionElementToken(QueryToken parent, CollectionElementType type) : base(parent) { elementType = parent.Type.ElementType(); if (elementType == null) throw new InvalidOperationException("not a collection"); this.CollectionElementType = type; }
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; }
internal CollectionElementToken(QueryToken parent, CollectionElementType type) : base(parent) { elementType = parent.Type.ElementType(); if (elementType == null) { throw new InvalidOperationException("not a collection"); } this.CollectionElementType = type; }
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()); }
public override string NiceName() { if (!CollectionElementType.IsElement()) { return(null); } Type parentElement = elementType.CleanType(); if (parentElement.IsModifiableEntity()) { return(parentElement.NiceName()); } return("Element of " + Parent.NiceName()); }
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; } } }
public override string ToString() { return(CollectionElementType.NiceToString()); }
public static bool IsElement(this CollectionElementType cet) { return(cet == CollectionElementType.Element || cet == CollectionElementType.Element2 || cet == CollectionElementType.Element3); }