Ejemplo n.º 1
0
        private IMethodReturn RetrieveBuilds(IMethodInvocation input, GetNextHandlerDelegate getNext)
        {
            RetrieveBuildsCacheKey cacheKey = new RetrieveBuildsCacheKey((RetrieveBuildsRequest)input.Arguments[0]);
            string key = cacheKey.ToString();

            if (!_buildsCache.ContainsKey(key))
            {
                RetrieveBuildsResponse retrieveBuildsResponse = (RetrieveBuildsResponse)getNext()(input, getNext).ReturnValue;
                _buildsCache.TryAdd(key, retrieveBuildsResponse);
            }

            RetrieveBuildsResponse cachedResponse;

            _buildsCache.TryGetValue(key, out cachedResponse);

            return(input.CreateMethodReturn(cachedResponse));
        }
        public override IEnumerable <IDriveItem> GetChildItems(object dynamicParameters)
        {
            GetChildDynamicParameters parameter = dynamicParameters as GetChildDynamicParameters;
            RetrieveBuildsResponse    retrieveBuildsResponse = Project.ProjectCollection.Tfs.DataService.RetrieveBuilds(new RetrieveBuildsRequest(Project, parameter.Status));

            IEnumerable <IDriveItem> builds = retrieveBuildsResponse.Builds.Select(token => new TfsBuild(token.Value <string>("buildNumber"), this)
            {
                Id           = token.Value <string>("id"),
                Result       = token.Value <string>("result"),
                CompletedOn  = token.Value <DateTime>("completedOn"),
                RequestedFor = token.Value <string>("requestedOn"),
                Status       = token.Value <string>("status"),
                Links        = new Links(token)
            });

            return(builds);
        }