示例#1
0
        public async Task <QueryResult <Neuron> > SendQueryInternal(string queryUrl, string bearerToken, CancellationToken token = default)
        {
            QueryResult <Neuron> result = new QueryResult <Neuron>()
            {
                Items = new Neuron[0]
            };

            if (QueryUrl.TryParse(queryUrl, out QueryUrl request))
            {
                NeuronQuery query = NeuronQuery.TryParse(request.QueryString, out NeuronQuery nquery) ?
                                    nquery :
                                    new NeuronQuery();

                if (request.Id.Length > 0)
                {
                    if (request.HasRelatives)
                    {
                        // http://[avatar]/cortex/neurons/[id]/relatives/[id2]
                        if (request.Id2.Length > 0)
                        {
                            result = await this.GetNeuronByIdInternal(request.AvatarUrl, request.Id2, request.Id, query, bearerToken, token);
                        }
                        // http://[avatar]/cortex/neurons/[id]/relatives
                        else
                        {
                            result = await this.GetNeuronsInternal(request.AvatarUrl, request.Id, query, bearerToken, token);
                        }
                    }
                    else
                    {
                        // http://[avatar]/cortex/neurons/[id]
                        result = await this.GetNeuronByIdInternal(request.AvatarUrl, request.Id, query, bearerToken, token);
                    }
                }
                // http://[avatar]/cortex/neurons
                else
                {
                    result = await this.GetNeuronsInternal(request.AvatarUrl, request.Id, query, bearerToken, token);
                }
            }

            return(result);
        }
示例#2
0
 internal static NeuronQuery ParseNeuronQueryOrEmpty(string queryString)
 {
     return(NeuronQuery.TryParse(queryString, out NeuronQuery query) ? query : new NeuronQuery());
 }