public static IEnumerable <Url> GetUrls( this AppCmd appCmd) { foreach (var site in appCmd.GetLines("list sites /text:name")) { foreach (var binding in appCmd.GetLines($"list site \"{site}\" /text:bindings").SelectMany(s => s.Split(','))) { foreach (var app in appCmd.GetLines($"list app /site.name:\"{site}\" /text:path")) { Url url; try { url = new Url(site, binding, app); } catch { continue; } yield return(url); } } } }
public static IEnumerable <string> GetHosts( this AppCmd appCmd) { foreach (var binding in appCmd.GetLines("list sites /text:bindings") .SelectMany(s => s.Split(','))) { var match = Regex.Match(binding, @"(https?)/(.*):(\d+):(?<host>.*)"); yield return(match.Groups["host"].Value); } }