DynamicRest.TemplatedUriBuilder.BuildBaseUri C# (CSharp) Method

BuildBaseUri() private method

private BuildBaseUri ( string operationName, StringBuilder uriBuilder ) : void
operationName string
uriBuilder StringBuilder
return void
        private void BuildBaseUri(string operationName, StringBuilder uriBuilder)
        {
            var values = new List<object>();
            _addedParameters = null;

            string rewrittenUriFormat = TokenFormatRewriteRegex.Replace(UriTemplate, delegate(Match m) {
                Group startGroup = m.Groups["start"];
                Group propertyGroup = m.Groups["property"];
                Group formatGroup = m.Groups["format"];
                Group endGroup = m.Groups["end"];

                if ((operationName.Length != 0) && String.CompareOrdinal(propertyGroup.Value, "operation") == 0) {
                    values.Add(operationName);
                }
                else if (this.ParametersStore != null && this.ParametersStore.Contains(propertyGroup.Value)) {
                    values.Add(this.ParametersStore.GetParameter(propertyGroup.Value));

                    if (_addedParameters == null) {
                        _addedParameters = new HashSet<string>(StringComparer.Ordinal);
                    }

                    _addedParameters.Add(propertyGroup.Value);
                }

                return new string('{', startGroup.Captures.Count) + (values.Count - 1) + formatGroup.Value + new string('}', endGroup.Captures.Count);
            });

            if (values.Count != 0) {
                uriBuilder.AppendFormat(CultureInfo.InvariantCulture, rewrittenUriFormat, values.ToArray());
            }
            else if (UriTemplate != rewrittenUriFormat) {
                throw new ArgumentException(string.Format("You are missing one or more expected template parameters in the uri: {0}", UriTemplate));
            }
            else {
                uriBuilder.Append(rewrittenUriFormat);
            }
        }