public static async setConnectionString()

in src/utility.ts [40:74]


    public static async setConnectionString(id: string, name: string, helpfile: string = "iot-hub-connection-string.md") {
        TelemetryClient.sendEvent("General.SetConfig.Popup");
        return new Promise<string>((resolve) => {
            let value: string | PromiseLike<string>;
            const input = vscode.window.createInputBox();
            input.prompt = name;
            input.placeholder = Constants.ConnectionStringFormat[id];
            input.ignoreFocusOut = true;
            input.onDidAccept(async () => {
                value = input.value;
                if (this.isValidConnectionString(id, value)) {
                    TelemetryClient.sendEvent("General.SetConfig.Done", { Result: "Success" });
                    await CredentialStore.setPassword(id, value);
                    if (id === Constants.IotHubConnectionStringKey) {
                        await CredentialStore.setPassword(Constants.IotHubEventHubConnectionStringKey, undefined);
                        await Utility.deleteIoTHubInfo();
                    }
                    resolve(value);
                    input.dispose();
                } else {
                    TelemetryClient.sendEvent("General.SetConfig.Done", { Result: "Fail" });
                    vscode.commands.executeCommand("markdown.showPreview", vscode.Uri.file(Constants.ExtensionContext.asAbsolutePath(path.join("resources", helpfile))));
                    input.validationMessage = `The format should be "${Constants.ConnectionStringFormat[id]}"`;
                }
            });
            input.onDidHide(() => {
                resolve();
                input.dispose();
                if (!value) {
                    this.showIoTHubInformationMessage();
                }
            });
            input.show();
        });
    }