Exemple #1
0
        private List <Credential_v2> ExtractCredentials(string[] input)
        {
            var list  = new List <Credential_v2>();
            var item  = new Credential_v2();
            var last  = "";
            var count = 0;

            foreach (var l in input)
            {
                if (l == String.Empty)
                {
                    count++;
                }

                if (last != String.Empty && l == String.Empty)
                {
                    list.Add(item);
                    item = new Credential_v2();
                }
                else
                {
                    var parts = l.Split(' ');
                    foreach (var p in parts)
                    {
                        UpdateParams(ref item, p);
                    }
                }
                last = l;
            }

            if (last != "")
            {
                if (list.Count > 0 && !list.Last().Equals(item))
                {
                    list.Add(item);
                }
            }

            Console.WriteLine(count);
            Console.WriteLine(list.Count);

            return(list);
        }
Exemple #2
0
        private void UpdateParams(ref Credential_v2 item, string p)
        {
            var param = p.Split(':');

            if (param[0] == "byr")
            {
                item.byr = param[1]; item.hasByr = true;
            }
            if (param[0] == "iyr")
            {
                item.iyr = param[1]; item.hasIyr = true;
            }
            if (param[0] == "eyr")
            {
                item.eyr = param[1]; item.hasEyr = true;
            }
            if (param[0] == "hgt")
            {
                item.hgt = param[1]; item.hasHgt = true;
            }
            if (param[0] == "hcl")
            {
                item.hcl = param[1]; item.hasHcl = true;
            }
            if (param[0] == "ecl")
            {
                item.ecl = param[1]; item.hasEcl = true;
            }
            if (param[0] == "pid")
            {
                item.pid = param[1]; item.hasPid = true;
            }
            if (param[0] == "cid")
            {
                item.cid = param[1]; item.hasCid = true;
            }
        }