Exemplo n.º 1
0
    public static string?CanOrder(QueryToken token)
    {
        if (token == null)
        {
            return("No column selected");
        }

        if (token.Type.IsEmbeddedEntity() && !OrderAdapters.Any(a => a(token) != null))
        {
            return("{0} can not be ordered".FormatWith(token.Type.NicePluralName()));
        }

        if (QueryToken.IsCollection(token.Type))
        {
            return("Collections can not be ordered");
        }

        if (token.HasAllOrAny())
        {
            return("'{0}', '{1}', '{2}' or '{3}' can not be ordered".FormatWith(
                       CollectionAnyAllType.All.NiceToString(),
                       CollectionAnyAllType.Any.NiceToString(),
                       CollectionAnyAllType.NoOne.NiceToString(),
                       CollectionAnyAllType.AnyNo.NiceToString()));
        }

        return(null);
    }
Exemplo n.º 2
0
        static string CanAny(QueryToken token)
        {
            if (token == null)
                return TemplateTokenMessage.NoColumnSelected.NiceToString();

            if (token.HasAllOrAny())
                return TemplateTokenMessage.YouCannotAddBlocksWithAllOrAny.NiceToString();

            return null;
        }
Exemplo n.º 3
0
        static string CanIf(QueryToken token)
        {
            if (token == null)
                return TemplateTokenMessage.NoColumnSelected.NiceToString();

            if (token.Type != typeof(string) && token.Type != typeof(byte[]) && token.Type.ElementType() != null)
                return TemplateTokenMessage.YouCannotAddIfBlocksOnCollectionFields.NiceToString();

            if (token.HasAllOrAny())
                return TemplateTokenMessage.YouCannotAddBlocksWithAllOrAny.NiceToString();

            return null;
        }
Exemplo n.º 4
0
        static string CanAny(QueryToken token)
        {
            if (token == null)
            {
                return(TemplateTokenMessage.NoColumnSelected.NiceToString());
            }

            if (token.HasAllOrAny())
            {
                return(TemplateTokenMessage.YouCannotAddBlocksWithAllOrAny.NiceToString());
            }

            return(null);
        }
Exemplo n.º 5
0
        static string CanForeach(QueryToken token)
        {
            if (token == null)
                return TemplateTokenMessage.NoColumnSelected.NiceToString();

            if (token.Type != typeof(string) && token.Type != typeof(byte[]) && token.Type.ElementType() != null)
                return TemplateTokenMessage.YouHaveToAddTheElementTokenToUseForeachOnCollectionFields.NiceToString();

            if (token.Key != "Element" || token.Parent == null || token.Parent.Type.ElementType() == null)
                return TemplateTokenMessage.YouCanOnlyAddForeachBlocksWithCollectionFields.NiceToString();

            if (token.HasAllOrAny())
                return TemplateTokenMessage.YouCannotAddBlocksWithAllOrAny.NiceToString();

            return null;
        }
Exemplo n.º 6
0
        static string CanIf(QueryToken token)
        {
            if (token == null)
            {
                return(TemplateTokenMessage.NoColumnSelected.NiceToString());
            }

            if (token.Type != typeof(string) && token.Type != typeof(byte[]) && token.Type.ElementType() != null)
            {
                return(TemplateTokenMessage.YouCannotAddIfBlocksOnCollectionFields.NiceToString());
            }

            if (token.HasAllOrAny())
            {
                return(TemplateTokenMessage.YouCannotAddBlocksWithAllOrAny.NiceToString());
            }

            return(null);
        }
Exemplo n.º 7
0
    public static string?CanColumn(QueryToken token)
    {
        if (token == null)
        {
            return("No column selected");
        }

        if (token.Type != typeof(string) && token.Type != typeof(byte[]) && token.Type.ElementType() != null)
        {
            return("You can not add collections as columns");
        }

        if (token.HasAllOrAny())
        {
            return("Columns can not contain '{0}', '{1}', {2} or {3}".FormatWith(
                       CollectionAnyAllType.All.NiceToString(),
                       CollectionAnyAllType.Any.NiceToString(),
                       CollectionAnyAllType.NoOne.NiceToString(),
                       CollectionAnyAllType.AnyNo.NiceToString()));
        }

        return(null);
    }
Exemplo n.º 8
0
        static string CanForeach(QueryToken token)
        {
            if (token == null)
            {
                return(TemplateTokenMessage.NoColumnSelected.NiceToString());
            }

            if (token.Type != typeof(string) && token.Type != typeof(byte[]) && token.Type.ElementType() != null)
            {
                return(TemplateTokenMessage.YouHaveToAddTheElementTokenToUseForeachOnCollectionFields.NiceToString());
            }

            if (token.Key != "Element" || token.Parent == null || token.Parent.Type.ElementType() == null)
            {
                return(TemplateTokenMessage.YouCanOnlyAddForeachBlocksWithCollectionFields.NiceToString());
            }

            if (token.HasAllOrAny())
            {
                return(TemplateTokenMessage.YouCannotAddBlocksWithAllOrAny.NiceToString());
            }

            return(null);
        }
Exemplo n.º 9
0
        public static string CanOrder(QueryToken token)
        {
            if (token == null)
                return "No column selected"; 

            if (token.Type.IsEmbeddedEntity())
                return "{0} can not be ordered".Formato(token.Type.NicePluralName());

            if (token.HasAllOrAny())
                return "Columns can not contain '{0}', '{1}', {2} or {3}".Formato(
                    CollectionElementType.All.NiceToString(),
                    CollectionElementType.Any.NiceToString(),
                    CollectionElementType.NoOne.NiceToString(),
                    CollectionElementType.AnyNo.NiceToString());

            return null;
        }
Exemplo n.º 10
0
        public static string CanColumn(QueryToken token)
        {
            if (token == null)
                return "No column selected"; 

            if (token.Type != typeof(string) && token.Type != typeof(byte[]) && token.Type.ElementType() != null)
                return "You can not add collections as columns";

            if (token.HasAllOrAny())
                return "Columns can not contain '{0}', '{1}', {2} or {3}".Formato(
                    CollectionElementType.All.NiceToString(), 
                    CollectionElementType.Any.NiceToString(),
                    CollectionElementType.NoOne.NiceToString(),
                    CollectionElementType.AnyNo.NiceToString());

            return null; 
        }