コード例 #1
0
        public async Task <HttpResponseMessage> ListProjectApiVersions(string projectName)
        {
            var project = await this
                          .GetProjectDataProvider()
                          .FindProject(
                organizationId: Project.GlobalProject,
                projectId: projectName)
                          .ConfigureAwait(continueOnCapturedContext: false);

            if (project == null)
            {
                throw new ErrorResponseMessageException(
                          httpStatus: HttpStatusCode.NotFound,
                          errorCode: ErrorResponseCode.ProjectNotFound,
                          errorMessage: string.Format("The project with name {0} was not found", projectName));
            }

            var apiVersions = await this
                              .GetApiVersionDataProvider()
                              .FindApiVersions(
                organizationId: Project.GlobalProject,
                projectId: projectName)
                              .ConfigureAwait(continueOnCapturedContext: false);

            // TODO: Move the $expand logic into query string reader
            var queryStringReader = new QueryStringReader(requestUri: this.Request.RequestUri);
            var expandProject     = queryStringReader.QueryParameters.ContainsKey("$expand") && queryStringReader.QueryParameters["$expand"].EqualsInsensitively("project");

            return(this.Request.CreateResponse(
                       statusCode: HttpStatusCode.OK,
                       value: apiVersions.Results.CoalesceEnumerable().Select(apiVersion => apiVersion.ToDefinition(expandProject ? project : null)),
                       configuration: this.HttpConfiguration,
                       encodedContinuationToken: null));
        }
コード例 #2
0
        public RemoteRunStatLightSystem(Assembly assemblyToTest, Action<UIElement> rootVisualActionOnReady)
        {
            _assemblyToTest = assemblyToTest;
            SetPostbackUri(null);
            IQueryStringReader queryStringReader = new QueryStringReader();
            string postbackUrl = queryStringReader.GetValueOrDefault(StatLightServiceRestApi.StatLightResultPostbackUrl, default(string));
            if (postbackUrl != default(string))
            {
                Console.WriteLine("postbackUrl={0}".FormatWith(postbackUrl));
                SetPostbackUri(new Uri(postbackUrl));
            }

            OnReadySetupRootVisual(rootVisualActionOnReady);
        }
コード例 #3
0
        public RemoteRunStatLightSystem(Assembly assemblyToTest, Action <UIElement> rootVisualActionOnReady)
        {
            _assemblyToTest = assemblyToTest;
            SetPostbackUri(null);
            IQueryStringReader queryStringReader = new QueryStringReader();
            string             postbackUrl       = queryStringReader.GetValueOrDefault(StatLightServiceRestApi.StatLightResultPostbackUrl, default(string));

            if (postbackUrl != default(string))
            {
                Console.WriteLine("postbackUrl={0}".FormatWith(postbackUrl));
                SetPostbackUri(new Uri(postbackUrl));
            }

            OnReadySetupRootVisual(rootVisualActionOnReady);
        }
コード例 #4
0
        public QueryParserBenchmarks()
        {
            IJsonApiOptions options = new JsonApiOptions
            {
                EnableLegacyFilterNotation = true
            };

            IResourceGraph resourceGraph = DependencyFactory.CreateResourceGraph(options);

            var request = new JsonApiRequest
            {
                PrimaryResource = resourceGraph.GetResourceContext(typeof(BenchmarkResource))
            };

            _queryStringReaderForSort = CreateQueryParameterDiscoveryForSort(resourceGraph, request, options, _queryStringAccessor);
            _queryStringReaderForAll  = CreateQueryParameterDiscoveryForAll(resourceGraph, request, options, _queryStringAccessor);
        }
コード例 #5
0
        public async Task <HttpResponseMessage> ListProjects()
        {
            var projects = await this
                           .GetProjectDataProvider()
                           .FindProjects(organizationId: Project.GlobalProject)
                           .ConfigureAwait(continueOnCapturedContext: false);

            // TODO: Move the $expand logic into query string reader
            var queryStringReader = new QueryStringReader(requestUri: this.Request.RequestUri);
            var expandApiVersions = queryStringReader.QueryParameters.ContainsKey("$expand") && queryStringReader.QueryParameters["$expand"].EqualsInsensitively("apiVersions");

            IEnumerable <ApiVersion> apiVersions = null;

            if (expandApiVersions)
            {
                var allApiVersions = await this
                                     .GetApiVersionDataProvider()
                                     .FindApiVersions(organizationId: Project.GlobalProject)
                                     .ConfigureAwait(continueOnCapturedContext: false);

                apiVersions = allApiVersions.Results.CoalesceEnumerable();
            }

            var projectDefinitions = projects.Results
                                     .CoalesceEnumerable()
                                     .Select(project =>
            {
                ApiVersionDefinition[] projectApiVersions = null;
                if (expandApiVersions)
                {
                    projectApiVersions = apiVersions
                                         .Where(apiVersion => apiVersion.ProjectId.EqualsInsensitively(project.ProjectId))
                                         .SelectArray(apiVersion => apiVersion.ToDefinition());
                }

                return(project.ToDefinition(apiVersions: projectApiVersions));
            });

            return(this.Request.CreateResponse(
                       statusCode: HttpStatusCode.OK,
                       value: projectDefinitions,
                       configuration: this.HttpConfiguration,
                       encodedContinuationToken: null));
        }