コード例 #1
0
        private void TestUpdate_Click(object sender, EventArgs e)
        {
            Indexes.Clear();
            indexesLength      = 0;
            CurrentSearchIndex = 0;
            var transforms = Transformations.Select(x => new TrackedTransformation
            {
                Method = x
            }).ToArray();
            int updatedVideos = 0;

            foreach (var video in Videos)
            {
                bool updated = false;
                foreach (var transformation in transforms)
                {
                    var transformResult = AdditionalMethods.DoReplacements(video.DisplayDescription, transformation.Method);
                    if (transformResult.Item2)
                    {
                        updated = true;
                        video.DisplayDescription       = transformResult.Item4;
                        transformation.TransformCount += transformResult.Item3;
                    }
                }

                if (updated)
                {
                    updatedVideos++;
                }
            }

            UpdateDescriptions.Text = $"Upload {updatedVideos} Changes";

            var response = $"Test Updated {updatedVideos} videos\r\n";

            foreach (var transform in transforms)
            {
                if (transform.Method.Method == AdditionalMethods.StringTransformation.TransformationMethod.Replace)
                {
                    response += $"Replaced {transform.TransformCount} occurrences of {transform.Method.PrimaryValue} with {transform.Method.SecondaryValue}\r\n";
                }
                else if (transform.Method.Method == AdditionalMethods.StringTransformation.TransformationMethod.Remove)
                {
                    response += $"Removed {transform.TransformCount} occurrences of {transform.Method.PrimaryValue}\r\n";
                }
            }
            VideoInformation.Text = NewLineFix(string.Join("\r\n----------\r\n", Videos.Select(x => $"Title: {x.Video.Snippet.Title} ({x.Video.Id})\r\n----------\r\n{x.DisplayDescription}")));
            LogMessage("Tested Descriptions update.");
            LogMessage(response);
            UpdateDescriptionTextChange();
        }