iRacingSdkWrapper.SessionInfo.FixYaml C# (CSharp) Method

FixYaml() private method

private FixYaml ( string yaml ) : void
yaml string
return void
        private void FixYaml(string yaml)
        {
            // Quick hack: if there's more than 1 colon ":" in a line, keep only the first
            using (var reader = new StringReader(yaml))
            {
                var builder = new StringBuilder();
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Count(c => c == ':') > 1)
                    {
                        var chars = line.ToCharArray();
                        bool foundFirst = false;
                        for (int i = 0; i < chars.Length; i++)
                        {
                            var c = chars[i];
                            if (c == ':')
                            {
                                if (!foundFirst)
                                {
                                    foundFirst = true;
                                    continue;
                                }
                                chars[i] = '-';
                            }
                        }
                        line = new string(chars);
                    }
                    builder.AppendLine(line);
                }
                _yaml = builder.ToString();
            }

            // Incorrect setup info dump fix: remove the setup info
            var indexOfSetup = _yaml.IndexOf("CarSetup:");
            if (indexOfSetup > 0)
            {
                _yaml = _yaml.Substring(0, indexOfSetup);
            }
        }