OpenSlx.Lib.Utility.LegacySlx.SlxConnectionInfo.ListAllConnections C# (CSharp) Method

ListAllConnections() public static method

Read list of connections defined in registry and return them in order. The connections don't include the password as this is not stored in the registry. If no connection is defined, an empty list is returned.
public static ListAllConnections ( ) : IList
return IList
        public static IList<SlxConnectionInfo> ListAllConnections()
        {
            List<SlxConnectionInfo> list = new List<SlxConnectionInfo>();
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\SalesLogix\ADOLogin");
            if (rk != null)
            {
                try
                {
                    String[] connectionKeyNames = rk.GetSubKeyNames();
                    foreach (String keyName in connectionKeyNames)
                    {
                        RegistryKey conKey = rk.OpenSubKey(keyName);
                        try
                        {
                            if (conKey != null && !String.IsNullOrEmpty((String)conKey.GetValue("Data Source")))
                            {
                                list.Add(new SlxConnectionInfo()
                                {
                                    Server = (String)conKey.GetValue("Data Source"),
                                    Database = (String)conKey.GetValue("Initial Catalog"),
                                    Alias = (String)conKey.GetValue("Alias")
                                });
                            }
                        }
                        finally
                        {
                            conKey.Close();
                        }
                    }
                }
                finally
                {
                    rk.Close();
                }
            }
            return list;
        }