/// <summary> /// Gets all the resources matching the type within the resource. /// </summary> /// <param name="resource">The resource.</param> /// <param name="model">The model to search.</param> /// <param name="relationshipType">The type of relationship to filter by.</param> /// <param name="type">The resource type.</param> /// <returns>A list of the <see cref="ResourceItem"/> matching the pattern.</returns> public static List <ResourceItem> FindRelatedResourcesByType(this ResourceItem resource, AzureIntegrationServicesModel model, ResourceRelationshipType relationshipType, string type) { _ = resource = resource ?? throw new ArgumentNullException(nameof(resource)); var relatedResources = new List <ResourceItem>(); var children = resource.ResourceRelationships?.Where(r => r.ResourceRelationshipType == relationshipType); if (children != null && children.Any()) { foreach (var child in children) { var relatedResource = model.FindResourceByRefId(child.ResourceRefId); if (relatedResource != null && relatedResource.Type == type) { relatedResources.Add(relatedResource); } } } return(relatedResources); }