public static AccountData FromString()

in Hands-on lab/lab-files/Tools/CustomerProfileJsonDataGenerator/Models/AccountData.cs [20:53]


        public static AccountData FromString(string line, string header)
        {
            if (string.IsNullOrWhiteSpace(line))
            {
                throw new ArgumentException($"{nameof(line)} cannot be null, empty, or only whitespace");
            }

            var tokens = line.Split(',');
            if (tokens.Length != 6)
            {
                throw new ArgumentException($"Invalid record: {line}");
            }

            var accountData = new AccountData
            {
                CsvString = line,
                CsvHeader = header
            };
            try
            {
                accountData.AccountID = tokens[0];
                accountData.AccountPostalCode = tokens[1];
                accountData.AccountState = tokens[2];
                accountData.AccountCountry = tokens[3];
                accountData.AccountAge = int.TryParse(tokens[4], out var iresult) ? iresult : 0;
                accountData.IsUserRegistered = bool.TryParse(tokens[5], out var bresult) && bresult;

                return accountData;
            }
            catch (Exception ex)
            {
                throw new ArgumentException($"Invalid record: {line}", ex);
            }
        }