/// <summary>
            /// Creates a new <see cref="ResourceIdScope"/>
            /// </summary>
            /// <param name="pathSegments">The scope path segments</param>
            /// <param name="output">The scope output</param>
            public static bool TryParse(IEnumerable <string> pathSegments, out ResourceIdScope output)
            {
                output = null;

                var segmentLength = pathSegments.Count();

                if (segmentLength < 3 || segmentLength % 2 != 1)
                {
                    return(false);
                }

                output = ResourceIdScope.Create(
                    pathSegments.First(),
                    pathSegments.Skip(1).Where((_, i) => i % 2 == 0),
                    pathSegments.Skip(1).Where((_, i) => i % 2 == 1));
                return(true);
            }
 /// <summary>
 /// Enumerates the parent resource Ids
 /// </summary>
 /// <param name="orderByDepthAscending">Order by depth ascending?</param>
 public IEnumerable <ResourceIdScope> GetParents(bool orderByDepthAscending)
 {
     if (orderByDepthAscending)
     {
         for (var i = 1; i < this.TypeHierarchy.Count; i++)
         {
             yield return(ResourceIdScope.Create(
                              providerNamespace: this.ProviderNamespace,
                              typeHierarchy: this.TypeHierarchy.Take(i),
                              nameHierarchy: this.NameHierarchy.Take(i)));
         }
     }
     else
     {
         for (var i = this.TypeHierarchy.Count - 1; i > 0; i--)
         {
             yield return(ResourceIdScope.Create(
                              providerNamespace: this.ProviderNamespace,
                              typeHierarchy: this.TypeHierarchy.Take(i),
                              nameHierarchy: this.NameHierarchy.Take(i)));
         }
     }
 }
 /// <summary>
 /// Generates a child resource Id
 /// </summary>
 /// <param name="nestedType">The last segment of the child resource type</param>
 /// <param name="nestedName">The last segment of the child resource name</param>
 public ResourceIdScope GetChild(string nestedType, string nestedName)
 => ResourceIdScope.Create(
     providerNamespace: this.ProviderNamespace,
     typeHierarchy: this.TypeHierarchy.Concat(new[] { nestedType }),
     nameHierarchy: this.NameHierarchy.Concat(new[] { nestedName }));
 /// <summary>
 /// Creates a new <see cref="TenantLevelResourceId"/>
 /// </summary>
 /// <param name="subscriptionId">The subscription Id</param>
 /// <param name="resourceGroup">The resource group</param>
 /// <param name="providerNamespace">The provider namespace</param>
 /// <param name="typeHierarchy">The type hierarchy</param>
 /// <param name="nameHierarchy">The name hierarchy</param>
 public static ResourceGroupLevelResourceId Create(string subscriptionId, string resourceGroup, string providerNamespace, IEnumerable <string> typeHierarchy, IEnumerable <string> nameHierarchy)
 => new ResourceGroupLevelResourceId(subscriptionId, resourceGroup, ResourceIdScope.Create(providerNamespace, typeHierarchy, nameHierarchy), Enumerable.Empty <ResourceIdScope>());