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

ValidateResourceIds() private method

Validates a whole array of resource IDs, including that the count matches.
private ValidateResourceIds ( string resourceIds ) : void
resourceIds string
return void
        internal void ValidateResourceIds(string[] resourceIds)
        {
            GaxPreconditions.CheckNotNull(resourceIds, nameof(resourceIds));
            if (resourceIds.Length != ParameterCount)
            {
                throw new ArgumentException($"Expected {ParameterCount} ids, got {resourceIds.Length}", nameof(resourceIds));
            }
            for (int i = 0; i < resourceIds.Length; i++)
            {
                ValidateResourceId(i, resourceIds[i]);
            }
        }

Usage Example

示例#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);
 }
All Usage Examples Of Google.Api.Gax.PathTemplate::ValidateResourceIds