/// <summary> /// Returns information about the available SQL Server LocalDB instances. /// </summary> /// <returns> /// An <see cref="IList<ISqlLocalDbInstanceInfo>"/> containing information /// about the available SQL Server LocalDB instances on the current machine. /// </returns> public virtual IList <ISqlLocalDbInstanceInfo> GetInstances() { IList <string> instanceNames = _localDB.GetInstanceNames(); List <ISqlLocalDbInstanceInfo> instances = new List <ISqlLocalDbInstanceInfo>(); if (instanceNames != null) { foreach (string name in instanceNames) { ISqlLocalDbInstanceInfo info = _localDB.GetInstanceInfo(name); instances.Add(info); } } return(instances); }
/// <summary> /// Returns information about the available SQL Server LocalDB instances. /// </summary> /// <param name="api">The <see cref="ISqlLocalDbApi"/> to use to enumerate the instances.</param> /// <returns> /// An <see cref="IReadOnlyList{ISqlLocalDbInstanceInfo}"/> containing information /// about the available SQL Server LocalDB instances on the current machine. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="api"/> is <see langword="null"/>. /// </exception> public static IReadOnlyList <ISqlLocalDbInstanceInfo> GetInstances(this ISqlLocalDbApi api) { if (api == null) { throw new ArgumentNullException(nameof(api)); } IReadOnlyList <string> instanceNames = api.GetInstanceNames(); var instances = new List <ISqlLocalDbInstanceInfo>(instanceNames?.Count ?? 0); if (instanceNames != null) { foreach (string name in instanceNames) { ISqlLocalDbInstanceInfo info = api.GetInstanceInfo(name); instances.Add(info); } } return(instances); }