Google.Api.Gax.PathTemplate.ReplaceParameters C# (CSharp) Method

ReplaceParameters() private method

Returns a string representation of the template with parameters replaced by resource IDs.
private ReplaceParameters ( string serviceName, string resourceIds ) : string
serviceName string The name of the service, for full resource names. May be null, to produce a relative resource name.
resourceIds string Resource IDs to interpolate the template with. Expected to have been validated already.
return string
        internal string ReplaceParameters(string serviceName, string[] resourceIds)
        {
            int nextIdIndex = 0;
            var result = new StringBuilder();
            if (serviceName != null)
            {
                result.Append("//").Append(serviceName);
            }
            foreach (var segment in _segments)
            {
                if (result.Length != 0)
                {
                    result.Append('/');
                }
                switch (segment.Kind)
                {
                    case SegmentKind.Literal:
                        result.Append(segment.Value);
                        break;
                    case SegmentKind.Wildcard:
                        result.Append(resourceIds[nextIdIndex++]);
                        break;
                    case SegmentKind.PathWildcard:
                        string path = resourceIds[nextIdIndex++];
                        result.Append(path);
                        if (path == "" && result.Length > 0)
                        {
                            // Swallow any slash that we've already added for this.
                            result.Length--;
                        }
                        break;
                }
            }
            return result.ToString();
        }