Represents a path template used for resource names which may be composed of multiple IDs.

Templates use a subset of the syntax of the API platform. See https://github.com/googleapis/googleapis/blob/master/google/api/http.proto for details of the API platform.

This class performs no URL escaping or unescaping. It is designed for use within GRPC, where no URL encoding is required.

示例#1
0
 /// <summary>
 /// Creates a resource name with the given template and resource IDs.
 /// The resource IDs are cloned, so later changes to <paramref name="resourceIds"/>
 /// are ignored. This constructor does not populate the <see cref="ServiceName"/> property,
 /// but that can be set after construction.
 /// </summary>
 /// <param name="template">The template for the new resource name. Must not be null.</param>
 /// <param name="resourceIds">The resource IDs to populate template parameters with. Must not be null.</param>
 public TemplatedResourceName(PathTemplate template, params string[] resourceIds)
 {
     Template = GaxPreconditions.CheckNotNull(template, nameof(Template));
     GaxPreconditions.CheckNotNull(resourceIds, nameof(resourceIds));
     // This is a somewhat annoying defensive copy. Given that we're usually going to just call ToString()
     // on the ResourceName, we don't really need the cloned array, or even the ResourceName itself.
     _resourceIds = (string[])resourceIds.Clone();
     template.ValidateResourceIds(_resourceIds);
 }
示例#2
0
 internal static TemplatedResourceName CreateWithShallowCopy(PathTemplate template, string serviceName, string[] resourceIds)
 {
     return(new TemplatedResourceName(template, serviceName, resourceIds, true));
 }
示例#3
0
 /// <summary>
 /// Private constructor used by internal code to avoid repeated cloning and validation.
 /// </summary>
 private TemplatedResourceName(PathTemplate template, string serviceName, string[] resourceIds, bool ignored)
 {
     Template          = GaxPreconditions.CheckNotNull(template, nameof(template));
     ServiceName       = serviceName;
     this._resourceIds = resourceIds;
 }
示例#4
0
 /// <summary>
 /// Creates a resource name with the given template and resource IDs.
 /// The resource IDs are cloned, so later changes to <paramref name="resourceIds"/>
 /// are ignored. This constructor does not populate the <see cref="ServiceName"/> property,
 /// but that can be set after construction.
 /// </summary>
 /// <param name="template">The template for the new resource name. Must not be null.</param>
 /// <param name="resourceIds">The resource IDs to populate template parameters with. Must not be null.</param>
 public ResourceName(PathTemplate template, params string[] resourceIds)
 {
     Template = GaxPreconditions.CheckNotNull(template, nameof(Template));
     GaxPreconditions.CheckNotNull(resourceIds, nameof(resourceIds));
     // This is a somewhat annoying defensive copy. Given that we're usually going to just call ToString()
     // on the ResourceName, we don't really need the cloned array, or even the ResourceName itself.
     _resourceIds = (string[]) resourceIds.Clone();
     template.ValidateResourceIds(_resourceIds);
 }
示例#5
0
 internal static ResourceName CreateWithShallowCopy(PathTemplate template, string serviceName, string[] resourceIds)
 {
     return new ResourceName(template, serviceName, resourceIds, true);
 }
示例#6
0
 /// <summary>
 /// Private constructor used by internal code to avoid repeated cloning and validation.
 /// </summary>
 private ResourceName(PathTemplate template, string serviceName, string[] resourceIds, bool ignored)
 {
     Template = GaxPreconditions.CheckNotNull(template, nameof(template));
     ServiceName = serviceName;
     this._resourceIds = resourceIds;
 }