private async Task UpdateDataSet()
        {
            var getDataStopWatch = new Stopwatch();

            getDataStopWatch.Start();

            using (var fileStream = await GetJsonStream())
                using (var jsonTextReader = new JsonTextReader(fileStream))
                {
                    var jsonSerializer = new JsonSerializer();
                    var data           = jsonSerializer.Deserialize <IDictionary <string, RepoSetDto> >(jsonTextReader);

                    var repoSetList = new Dictionary <string, RepoSetDefinition>(StringComparer.OrdinalIgnoreCase);

                    foreach (var repoInfo in data)
                    {
                        var repoSetDefinition = new RepoSetDefinition
                        {
                            AssociatedPersonSetName = repoInfo.Value.AssociatedPersonSetName,
                            LabelFilter             = repoInfo.Value.LabelFilter,
                            WorkingLabels           = repoInfo.Value.WorkingLabels,
                            RepoExtraLinks          = repoInfo.Value.RepoExtraLinks != null
                            ? repoInfo.Value.RepoExtraLinks
                                                      .Select(extraLink => new RepoExtraLink
                            {
                                Title = extraLink.Title,
                                Url   = extraLink.Url,
                            })
                                                      .ToList()
                            : new List <RepoExtraLink>(),
                            Repos = repoInfo.Value.Repos
                                    .Select(repoDef => new RepoDefinition(repoDef.Org, repoDef.Repo, (RepoInclusionLevel)Enum.Parse(typeof(RepoInclusionLevel), repoDef.InclusionLevel, ignoreCase: true)))
                                    .ToArray(),
                        };
                        repoSetList.Add(repoInfo.Key, repoSetDefinition);
                    }

                    // Atomically assign the entire data set
                    _repoSetList = repoSetList;
                }

            getDataStopWatch.Stop();

            var getDataEventTelemetry = new EventTelemetry
            {
                Name = "UpdateRepoSets",
            };

            getDataEventTelemetry.Properties.Add("durationInMilliseconds", getDataStopWatch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture));
            TelemetryClient.TrackEvent(getDataEventTelemetry);
        }
示例#2
0
        private async Task UpdateDataSet()
        {
            using (var fileStream = await GetJsonStream())
                using (var jsonTextReader = new JsonTextReader(fileStream))
                {
                    var jsonSerializer = new JsonSerializer();
                    var data           = jsonSerializer.Deserialize <IDictionary <string, RepoSetDto> >(jsonTextReader);

                    var repoSetList = new Dictionary <string, RepoSetDefinition>(StringComparer.OrdinalIgnoreCase);

                    foreach (var repoInfo in data)
                    {
                        var repoSetDefinition = new RepoSetDefinition
                        {
                            AssociatedPersonSetName = repoInfo.Value.AssociatedPersonSetName,
                            LabelFilter             = repoInfo.Value.LabelFilter,
                            WorkingLabels           = repoInfo.Value.WorkingLabels,
                            RepoExtraLinks          = repoInfo.Value.RepoExtraLinks != null
                            ? repoInfo.Value.RepoExtraLinks
                                                      .Select(extraLink => new RepoExtraLink
                            {
                                Title = extraLink.Title,
                                Url   = extraLink.Url,
                            })
                                                      .ToList()
                            : new List <RepoExtraLink>(),
                            Repos = repoInfo.Value.Repos
                                    .Select(repoDef => new RepoDefinition(repoDef.Org, repoDef.Repo, (RepoInclusionLevel)Enum.Parse(typeof(RepoInclusionLevel), repoDef.InclusionLevel, ignoreCase: true)))
                                    .ToArray(),
                        };
                        repoSetList.Add(repoInfo.Key, repoSetDefinition);
                    }

                    // Atomically assign the entire data set
                    _repoSetList = repoSetList;
                }
        }
        private async Task UpdateDataSet()
        {
            using (var fileStream = await GetJsonStream())
            using (var jsonTextReader = new JsonTextReader(fileStream))
            {
                var jsonSerializer = new JsonSerializer();
                var data = jsonSerializer.Deserialize<IDictionary<string, RepoSetDto>>(jsonTextReader);

                var repoSetList = new Dictionary<string, RepoSetDefinition>(StringComparer.OrdinalIgnoreCase);

                foreach (var repoInfo in data)
                {
                    var repoSetDefinition = new RepoSetDefinition
                    {
                        AssociatedPersonSetName = repoInfo.Value.AssociatedPersonSetName,
                        LabelFilter = repoInfo.Value.LabelFilter,
                        WorkingLabels = repoInfo.Value.WorkingLabels,
                        RepoExtraLinks = repoInfo.Value.RepoExtraLinks != null
                            ? repoInfo.Value.RepoExtraLinks
                                .Select(extraLink => new RepoExtraLink
                                {
                                    Title = extraLink.Title,
                                    Url = extraLink.Url,
                                })
                                .ToList()
                            : new List<RepoExtraLink>(),
                        Repos = repoInfo.Value.Repos
                            .Select(repoDef => new RepoDefinition(repoDef.Org, repoDef.Repo, (RepoInclusionLevel)Enum.Parse(typeof(RepoInclusionLevel), repoDef.InclusionLevel, ignoreCase: true)))
                            .ToArray(),
                    };
                    repoSetList.Add(repoInfo.Key, repoSetDefinition);
                }

                // Atomically assign the entire data set
                _repoSetList = repoSetList;
            }
        }