AcManager.Tools.Helpers.SteamIdHelper.TryToFind C# (CSharp) Méthode

TryToFind() public static méthode

public static TryToFind ( ) : IEnumerable
Résultat IEnumerable
        public static IEnumerable<SteamProfile> TryToFind() {
            // TODO: if (OptionForceValue != null) return OptionForceValue;

            Vdf parsed;
            try {
                var regKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam");
                if (regKey == null) yield break;

                var steamPath = regKey.GetValue("SteamPath").ToString();
                var config = File.ReadAllText(Path.Combine(steamPath, @"config", @"loginusers.vdf"));

                parsed = Vdf.Parse(config).Children.GetValueOrDefault("users");
                if (parsed == null) {
                    throw new Exception("Config is invalid");
                }
            } catch (Exception e) {
                NonfatalError.Notify("Can’t get Steam ID from its config", e);
                yield break;
            }
            
            string selectedId = null;
            try {
                var selectedKey = new IniFile(FileUtils.GetRaceIniFilename());
                selectedId = selectedKey["REMOTE"].GetNonEmpty("GUID");
            } catch (Exception) {
                // ignored
            }

            Vdf selectedSection;
            if (selectedId != null && parsed.Children.TryGetValue(selectedId, out selectedSection)) {
                yield return new SteamProfile(selectedId, selectedSection.Values.GetValueOrDefault("PersonaName"));
            }

            foreach (var pair in parsed.Children.Where(x => x.Key != selectedId)) {
                yield return new SteamProfile(pair.Key, pair.Value.Values.GetValueOrDefault("PersonaName"));
            }
        }