Esempio n. 1
0
        public Task <QueryResult <LabelList> > GetClanLabelsAsync(Query?query = default)
        {
            var request = new AutoValidatedRequest
            {
                Query = query,
                Uri   = "/labels/clans"
            };

            return(_gameData.QueryAsync <LabelList>(request));
        }
Esempio n. 2
0
        public Task <QueryResult <ClanWarLog> > GetClanWarLogAsync(string clanTag, Query?query = default)
        {
            var request = new AutoValidatedRequest
            {
                Query   = query,
                ClanTag = clanTag,
                Uri     = $"/clans/{clanTag}/warlog"
            };

            return(_gameData.QueryAsync <ClanWarLog>(request));
        }
Esempio n. 3
0
        private Query ProcessNode(AstNode root, Flags flags, out Props props)
        {
            if (++_parseDepth > MaxParseDepth)
            {
                throw XPathException.Create(SR.Xp_QueryTooComplex);
            }

            Debug.Assert(root != null, "root != null");
            Query?result = null;

            props = Props.None;
            switch (root.Type)
            {
            case AstNode.AstType.Axis:
                result = ProcessAxis((Axis)root, flags, out props);
                break;

            case AstNode.AstType.Operator:
                result = ProcessOperator((Operator)root, out props);
                break;

            case AstNode.AstType.Filter:
                result = ProcessFilter((Filter)root, flags, out props);
                break;

            case AstNode.AstType.ConstantOperand:
                result = new OperandQuery(((Operand)root).OperandValue);
                break;

            case AstNode.AstType.Variable:
                result = ProcessVariable((Variable)root);
                break;

            case AstNode.AstType.Function:
                result = ProcessFunction((Function)root, out props);
                break;

            case AstNode.AstType.Group:
                result = new GroupQuery(ProcessNode(((Group)root).GroupNode, Flags.None, out props));
                break;

            case AstNode.AstType.Root:
                result = new AbsoluteQuery();
                break;

            default:
                Debug.Fail("Unknown QueryType encountered!!");
                break;
            }
            --_parseDepth;
            return(result !);
        }
Esempio n. 4
0
        private Query[] GetParts()
        {
            LinkedList <Query> parts = new LinkedList <Query>();
            Query?query = Parent;

            while (query is not null)
            {
                parts.AddFirst(query);
                query = query.Parent;
            }

            return(parts.ToArray());
        }
Esempio n. 5
0
        public CD3D11QueryDesc
        (
            Query?query    = null,
            uint?miscFlags = null
        ) : this()
        {
            if (query is not null)
            {
                Query = query.Value;
            }

            if (miscFlags is not null)
            {
                MiscFlags = miscFlags.Value;
            }
        }
Esempio n. 6
0
        public CD3D11QueryDesc1
        (
            Query?query             = null,
            uint?miscFlags          = null,
            ContextType?contextType = null
        ) : this()
        {
            if (query is not null)
            {
                Query = query.Value;
            }

            if (miscFlags is not null)
            {
                MiscFlags = miscFlags.Value;
            }

            if (contextType is not null)
            {
                ContextType = contextType.Value;
            }
        }
Esempio n. 7
0
 /// <inheritdoc />
 public virtual Source <ILogDto> GetLogs(Query?query)
 {
     return(Logs
            .AsNoTracking()
            .AsSource <ILogDto>());
 }
Esempio n. 8
0
 private NumberFunctions(NumberFunctions other) : base(other)
 {
     _arg   = Clone(other._arg);
     _ftype = other._ftype;
 }
Esempio n. 9
0
 public NumberFunctions(FT ftype, Query?arg)
 {
     _arg   = arg;
     _ftype = ftype;
 }
Esempio n. 10
0
        private Query ProcessAxis(Axis root, Flags flags, out Props props)
        {
            Query?result = null;

            if (root.Prefix.Length > 0)
            {
                _needContext = true;
            }
            _firstInput = null;
            Query qyInput;

            {
                if (root.Input != null)
                {
                    Flags inputFlags = Flags.None;
                    if ((flags & Flags.PosFilter) == 0)
                    {
                        Axis?input = root.Input as Axis;
                        if (input != null)
                        {
                            if (
                                root.TypeOfAxis == Axis.AxisType.Child &&
                                input.TypeOfAxis == Axis.AxisType.DescendantOrSelf && input.NodeType == XPathNodeType.All
                                )
                            {
                                Query qyGrandInput;
                                if (input.Input != null)
                                {
                                    qyGrandInput = ProcessNode(input.Input, Flags.SmartDesc, out props);
                                }
                                else
                                {
                                    qyGrandInput = new ContextQuery();
                                    props        = Props.None;
                                }
                                result = new DescendantQuery(qyGrandInput, root.Name, root.Prefix, root.NodeType, false, input.AbbrAxis);
                                if ((props & Props.NonFlat) != 0)
                                {
                                    result = new DocumentOrderQuery(result);
                                }
                                props |= Props.NonFlat;
                                return(result);
                            }
                        }
                        if (root.TypeOfAxis == Axis.AxisType.Descendant || root.TypeOfAxis == Axis.AxisType.DescendantOrSelf)
                        {
                            inputFlags |= Flags.SmartDesc;
                        }
                    }

                    qyInput = ProcessNode(root.Input, inputFlags, out props);
                }
                else
                {
                    qyInput = new ContextQuery();
                    props   = Props.None;
                }
            }

            switch (root.TypeOfAxis)
            {
            case Axis.AxisType.Ancestor:
                result = new XPathAncestorQuery(qyInput, root.Name, root.Prefix, root.NodeType, false);
                props |= Props.NonFlat;
                break;

            case Axis.AxisType.AncestorOrSelf:
                result = new XPathAncestorQuery(qyInput, root.Name, root.Prefix, root.NodeType, true);
                props |= Props.NonFlat;
                break;

            case Axis.AxisType.Child:
                if ((props & Props.NonFlat) != 0)
                {
                    result = new CacheChildrenQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                }
                else
                {
                    result = new ChildrenQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                }
                break;

            case Axis.AxisType.Parent:
                result = new ParentQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                break;

            case Axis.AxisType.Descendant:
                if ((flags & Flags.SmartDesc) != 0)
                {
                    result = new DescendantOverDescendantQuery(qyInput, false, root.Name, root.Prefix, root.NodeType, /*abbrAxis:*/ false);
                }
                else
                {
                    result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.NodeType, false, /*abbrAxis:*/ false);
                    if ((props & Props.NonFlat) != 0)
                    {
                        result = new DocumentOrderQuery(result);
                    }
                }
                props |= Props.NonFlat;
                break;

            case Axis.AxisType.DescendantOrSelf:
                if ((flags & Flags.SmartDesc) != 0)
                {
                    result = new DescendantOverDescendantQuery(qyInput, true, root.Name, root.Prefix, root.NodeType, root.AbbrAxis);
                }
                else
                {
                    result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.NodeType, true, root.AbbrAxis);
                    if ((props & Props.NonFlat) != 0)
                    {
                        result = new DocumentOrderQuery(result);
                    }
                }
                props |= Props.NonFlat;
                break;

            case Axis.AxisType.Preceding:
                result = new PrecedingQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                props |= Props.NonFlat;
                break;

            case Axis.AxisType.Following:
                result = new FollowingQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                props |= Props.NonFlat;
                break;

            case Axis.AxisType.FollowingSibling:
                result = new FollSiblingQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                if ((props & Props.NonFlat) != 0)
                {
                    result = new DocumentOrderQuery(result);
                }
                break;

            case Axis.AxisType.PrecedingSibling:
                result = new PreSiblingQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                break;

            case Axis.AxisType.Attribute:
                result = new AttributeQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                break;

            case Axis.AxisType.Self:
                result = new XPathSelfQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                break;

            case Axis.AxisType.Namespace:
                if ((root.NodeType == XPathNodeType.All || root.NodeType == XPathNodeType.Element || root.NodeType == XPathNodeType.Attribute) && root.Prefix.Length == 0)
                {
                    result = new NamespaceQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                }
                else
                {
                    result = new EmptyQuery();
                }
                break;

            default:
                throw XPathException.Create(SR.Xp_NotSupported, _query !);
            }

            return(result);
        }
Esempio n. 11
0
 public NodeFunctions(FT funcType, Query?arg)
 {
     _funcType = funcType;
     _arg      = arg;
 }
        public override async ValueTask <IEnumerable <Message> > Messages(Query?objectValue, int channelId, IResolverContext context)
        {
            var messages = await _messages.GetMessagesAsync(channelId);

            return(messages);
        }
Esempio n. 13
0
 /// <inheritdoc />
 public virtual Source <IUserNotificationDto> GetUserNotifications(Query?query = null)
 {
     return(context.UserNotifications.AsSource <IUserNotificationDto>());
 }
Esempio n. 14
0
 public BooleanFunctions(FT funcType, Query?arg)
 {
     _arg      = arg;
     _funcType = funcType;
 }
Esempio n. 15
0
        public Task <QueryResult <LeagueSeasonList> > GetLeagueSeasonsAsync(int?leagueId, Query?query = default)
        {
            var request = new AutoValidatedRequest
            {
                Query    = query,
                LeagueId = leagueId,
                Uri      = $"/leagues/{leagueId}/seasons"
            };

            return(_gameData.QueryAsync <LeagueSeasonList>(request));
        }
Esempio n. 16
0
        public override async ValueTask <Channel?> Channel(Query?objectValue, int channelId, IResolverContext context)
        {
            var channel = await _channels.GetChannelAsync(channelId);

            return(channel);
        }
Esempio n. 17
0
        public override async ValueTask <IEnumerable <Channel> > Channels(Query?objectValue, IResolverContext context)
        {
            var channels = await _channels.GetChannelsAsync();

            return(channels);
        }
Esempio n. 18
0
        public Task <QueryResult <PlayerRankingList> > GetLeagueSeasonRankingsAsync(int?leagueId, string seasonId, Query?query = default)
        {
            var request = new AutoValidatedRequest
            {
                Query    = query,
                LeagueId = leagueId,
                SeasonId = seasonId,
                Uri      = $"/leagues/{leagueId}/seasons/{seasonId}"
            };

            return(_gameData.QueryAsync <PlayerRankingList>(request));
        }
Esempio n. 19
0
 private BooleanFunctions(BooleanFunctions other) : base(other)
 {
     _arg      = Clone(other._arg);
     _funcType = other._funcType;
 }
Esempio n. 20
0
        private Query ProcessFunction(Function root, out Props props)
        {
            props = Props.None;
            Query?qy = null;

            switch (root.TypeOfFunction)
            {
            case FT.FuncLast:
                qy     = new NodeFunctions(root.TypeOfFunction, null);
                props |= Props.HasLast;
                return(qy);

            case FT.FuncPosition:
                qy     = new NodeFunctions(root.TypeOfFunction, null);
                props |= Props.HasPosition;
                return(qy);

            case FT.FuncCount:
                return(new NodeFunctions(FT.FuncCount,
                                         ProcessNode((AstNode)(root.ArgumentList[0]), Flags.None, out props)
                                         ));

            case FT.FuncID:
                qy     = new IDQuery(ProcessNode((AstNode)(root.ArgumentList[0]), Flags.None, out props));
                props |= Props.NonFlat;
                return(qy);

            case FT.FuncLocalName:
            case FT.FuncNameSpaceUri:
            case FT.FuncName:
                if (root.ArgumentList != null && root.ArgumentList.Count > 0)
                {
                    return(new NodeFunctions(root.TypeOfFunction,
                                             ProcessNode((AstNode)(root.ArgumentList[0]), Flags.None, out props)
                                             ));
                }
                else
                {
                    return(new NodeFunctions(root.TypeOfFunction, null));
                }

            case FT.FuncString:
            case FT.FuncConcat:
            case FT.FuncStartsWith:
            case FT.FuncContains:
            case FT.FuncSubstringBefore:
            case FT.FuncSubstringAfter:
            case FT.FuncSubstring:
            case FT.FuncStringLength:
            case FT.FuncNormalize:
            case FT.FuncTranslate:
                return(new StringFunctions(root.TypeOfFunction, ProcessArguments(root.ArgumentList, out props)));

            case FT.FuncNumber:
            case FT.FuncSum:
            case FT.FuncFloor:
            case FT.FuncCeiling:
            case FT.FuncRound:
                if (root.ArgumentList != null && root.ArgumentList.Count > 0)
                {
                    return(new NumberFunctions(root.TypeOfFunction,
                                               ProcessNode((AstNode)root.ArgumentList[0], Flags.None, out props)
                                               ));
                }
                else
                {
                    return(new NumberFunctions(Function.FunctionType.FuncNumber, null));
                }

            case FT.FuncTrue:
            case FT.FuncFalse:
                return(new BooleanFunctions(root.TypeOfFunction, null));

            case FT.FuncNot:
            case FT.FuncLang:
            case FT.FuncBoolean:
                return(new BooleanFunctions(root.TypeOfFunction,
                                            ProcessNode((AstNode)root.ArgumentList[0], Flags.None, out props)
                                            ));

            case FT.FuncUserDefined:
                Debug.Assert(root.Prefix != null);
                Debug.Assert(root.Name != null);

                _needContext = true;
                if (!_allowCurrent && root.Name == "current" && root.Prefix.Length == 0)
                {
                    throw XPathException.Create(SR.Xp_CurrentNotAllowed);
                }
                if (!_allowKey && root.Name == "key" && root.Prefix.Length == 0)
                {
                    throw XPathException.Create(SR.Xp_InvalidKeyPattern, _query !);
                }
                qy     = new FunctionQuery(root.Prefix, root.Name, ProcessArguments(root.ArgumentList, out props));
                props |= Props.NonFlat;
                return(qy);

            default:
                throw XPathException.Create(SR.Xp_NotSupported, _query !);
            }
        }
Esempio n. 21
0
        public Task <QueryResult <PlayerVersusRankingList> > GetPlayerVersusRankingAsync(int?locationId, Query?query = default)
        {
            var request = new AutoValidatedRequest
            {
                Query      = query,
                LocationId = locationId,
                Uri        = $"/locations/{locationId}/rankings/players-versus"
            };

            return(_gameData.QueryAsync <PlayerVersusRankingList>(request));
        }
Esempio n. 22
0
        public Task <QueryResult <ClanMemberList> > GetClanMembersAsync(string clanTag, Query?query = default)
        {
            var request = new AutoValidatedRequest
            {
                Query   = query,
                ClanTag = clanTag,
                Uri     = $"/clans/{clanTag}/members"
            };

            return(_gameData.QueryAsync <ClanMemberList>(request));
        }