Пример #1
0
        private static void AddEnvironments(VSTSRelease_v1 vstsRelease, VSTSReleaseDetails releaseDetails)
        {
            if (vstsRelease == null || vstsRelease.Items == null)
            {
                throw new InvalidOperationException();
            }

            foreach (var environment in releaseDetails.Environments)
            {
                var node = vstsRelease.Items.FirstOrDefault(i => i.Name == environment.Name);

                if (node == null)
                {
                    node = new VSTSReleaseEnvironment
                    {
                        Name          = environment.Name,
                        EnvironmentId = environment.Id
                    };

                    Application.Current.Dispatcher.Invoke(() => vstsRelease.Add(node));
                }

                node.State = environment.State;
            }
        }
Пример #2
0
        private static VSTSReleaseEnvironment AddEnvironment(VSTSRelease_v1 release, ReleaseEnvironment environment)
        {
            if (!release.ReleaseId.HasValue)
            {
                throw new InvalidOperationException("Release id was not set.");
            }

            var newEnvironment = new VSTSReleaseEnvironment
            {
                Name          = environment.Name,
                EnvironmentId = environment.Id,
            };

            var dispatcher = Application.Current?.Dispatcher ?? Dispatcher.CurrentDispatcher;

            dispatcher.Invoke(() => release.Add(newEnvironment));

            return(newEnvironment);
        }