示例#1
0
        private static string CreateComparison(string label,
                                               Comparisons client,
                                               Func <Comparisons, Comparison> createCore)
        {
            label = $"[{label}]";
            var prefix = new string(' ', label.Length);

            var comparison = createCore(client);
            var cid        = comparison.Identifier;

            Console.WriteLine($"{label} Comparison ID: {cid}");
            Console.WriteLine($"{prefix} isReady: {comparison.Ready}");
            Console.WriteLine($"{prefix} Public URL: {client.PublicViewerURL(cid)}");
            Console.WriteLine($"{prefix} Signed URL: {client.SignedViewerURL(cid)}");

            var timeoutCount = 0;

            while (!comparison.Ready)
            {
                if (timeoutCount > 20)
                {
                    throw new TimeoutException("Timeout exceeded while waiting for comparison to be ready.");
                }

                Task.Delay(1000).Wait();
                comparison = client.Get(cid);
                timeoutCount++;
            }

            Console.WriteLine($"{label} Comparison ID: {cid}");
            Console.WriteLine($"{prefix} isReady: {comparison.Ready}");
            Console.WriteLine($"{prefix} Failed: {HasFailed(comparison)}");
            Console.WriteLine($"{prefix} Error: {comparison.ErrorMessage}");

            return(cid);
        }