Esempio n. 1
0
        public NameGenerator(RandomNameConfiguration configuration)
        {
            _random       = configuration.CreateRandom();
            _maleTable    = new RandomTable <string>(_random.Next);
            _femaleTable  = new RandomTable <string>(_random.Next);
            _surnameTable = new RandomTable <string>(_random.Next);

            _maxGivenNames = configuration.MaxGivenNames;

            var nameFiles  = configuration.GetCensusDataFiles();
            var convention = configuration.GetFileTypeConvention();

            foreach (var nameData in nameFiles.Where(convention.ContainsMaleNames).SelectMany(f => f.NameData))
            {
                _maleTable.Add(nameData.Name, nameData.Frequency);
            }

            foreach (var nameData in nameFiles.Where(convention.ContainsFemaleNames).SelectMany(f => f.NameData))
            {
                _femaleTable.Add(nameData.Name, nameData.Frequency);
            }

            foreach (var nameData in nameFiles.Where(convention.ContainsSurnames).SelectMany(f => f.NameData))
            {
                _surnameTable.Add(nameData.Name, nameData.Frequency);
            }
        }
Esempio n. 2
0
        public NameGenerator(RandomNameConfiguration configuration)
        {
            _random = configuration.CreateRandom();
            _maleTable = new RandomTable<string>(_random.Next);
            _femaleTable = new RandomTable<string>(_random.Next);
            _surnameTable = new RandomTable<string>(_random.Next);

            _maxGivenNames = configuration.MaxGivenNames;

            var nameFiles = configuration.GetCensusDataFiles();
            var convention = configuration.GetFileTypeConvention();

            foreach (var nameData in nameFiles.Where(convention.ContainsMaleNames).SelectMany(f => f.NameData))
                _maleTable.Add(nameData.Name, nameData.Frequency);

            foreach (var nameData in nameFiles.Where(convention.ContainsFemaleNames).SelectMany(f => f.NameData))
                _femaleTable.Add(nameData.Name, nameData.Frequency);

            foreach (var nameData in nameFiles.Where(convention.ContainsSurnames).SelectMany(f => f.NameData))
                _surnameTable.Add(nameData.Name, nameData.Frequency);
        }