/// <summary>
        /// Validates the license key using the InnerEye segmentation client.
        /// </summary>
        /// <param name="gatewayProcessorConfigProvider">Gateway processor config provider.</param>
        /// <param name="licenseKey">The license key to validate.</param>
        /// <param name="inferenceUri">Inference Uri to validate.</param>
        /// <returns>If valid and text to display with the validation result.</returns>
        internal static async Task <(bool Result, string ValidationText)> ValidateLicenseKeyAsync(GatewayProcessorConfigProvider gatewayProcessorConfigProvider, string licenseKey, Uri inferenceUri)
        {
            var validationText       = string.Empty;
            var processorSettings    = gatewayProcessorConfigProvider.ProcessorSettings();
            var existingInferenceUri = processorSettings.InferenceUri;
            var existingLicenseKey   = processorSettings.LicenseKey;

            try
            {
                // Update the settings for the Gateway.
                gatewayProcessorConfigProvider.SetProcessorSettings(inferenceUri, licenseKey);

                using (var segmentationClient = gatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient()())
                {
                    await segmentationClient.PingAsync();
                }

                return(true, validationText);
            }
            catch (AuthenticationException)
            {
                validationText = "Invalid product key";
            }
            catch (Exception)
            {
                validationText = "Unable to connect to inference service uri";
            }

            // Restore the previous config
            gatewayProcessorConfigProvider.SetProcessorSettings(existingInferenceUri, existingLicenseKey);

            return(false, validationText);
        }
        /// <summary>
        /// Handles the Load event of the LicenseKeyForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void LicenseKeyForm_Load(object sender, EventArgs e)
        {
            var processorSettings = _gatewayProcessorConfigProvider.ProcessorSettings();

            inferenceUriTextBox.Text = processorSettings.InferenceUri.AbsoluteUri;
            licenseKeyTextBox.Text   = processorSettings.LicenseKey;
        }