private Uri GenerateHttpUri(Uri uri)
        {
            string addr = $"http://{uri.Host}";

            if (uri.Port != 0)
            {
                addr += $":{uri.Port}";
            }

            foreach (string segment in uri.Segments)
            {
                string newSegment = WebUtility.UrlDecode(segment);
                if (newSegment == null)
                {
                    continue;
                }

                // ${field:RepeaterGroupForm.Id}
                if (newSegment.Contains("${"))
                {
                    newSegment = new StringSubstitutor().PerformSubstitutions(newSegment, null, this.Form);
                }

                addr += newSegment;
            }

            return(new Uri(addr));
        }
        private Uri ConstructWorkflowUri(IFormSubmissionFunction submissionFunc)
        {
            string workflow = new StringSubstitutor().PerformSubstitutions(submissionFunc.Workflow, null, this.Form);

            Uri uri = new Uri(workflow);

            switch (uri.Scheme.ToLower())
            {
            case "mockrest":
            {
                this.IsMockRest = true;
                Uri newUri = this.GenerateHttpUri(uri);
                return(newUri);
            }

            case "rest":
            {
                this.IsMockRest = ApplicationContext.Configuration.UseMocksForRestCalls;
                Uri newUri = this.GenerateHttpUri(uri);
                return(newUri);
            }
            }

            return(null);
        }
        /// <summary>
        /// Reads a line of text from the console. This is a virtual function so that subclasses
        /// can support other kinds of views.
        /// </summary>
        /// <returns>The string, or the default value if the user pressed the Return key.</returns>
        protected virtual string InputWithDefault()
        {
            string line = this.Input();

            if (string.IsNullOrEmpty(line) && this.SBSFormField.DefaultValue != null)
            {
                line = StringSubstitutor.SubstituteVariablesInExpression(this.SBSFormField.DefaultValue.ToString());
            }
            return(line);
        }
        public virtual void Render()
        {
            if (!this.CanDisplay)
            {
                return;
            }

            string sDefault = SBSFormField.DefaultValue != null ? $"({SBSFormField.DefaultValue.ToString()})" : "";

            sDefault = StringSubstitutor.SubstituteVariablesInExpression(sDefault);
            string prompt = this.SBSFormField.Prompt;

            if (prompt != null && prompt.StartsWith("$html:"))
            {
                prompt = prompt.Replace("$html:", "");
                prompt = HtmlRemoval.StripTagsRegex(prompt);
            }

            this.ColoredOutput($"({this.SBSFormField.FieldTypeName}) {prompt}: {sDefault}", ConsoleColor.Cyan);
        }