private static void CheckTimeGenerateList(int count, GenerateList func, IGetHashCode getHashCode) { Stopwatch stopwatch = new(); stopwatch.Start(); func(getHashCode, count); stopwatch.Stop(); Console.WriteLine($"Время генерации для {count} объектов: {stopwatch.ElapsedMilliseconds}"); }
private void CreatePersonList(IGetHashCode getHashCode, int count) { List <Human> persons = new(); Faker faker = new(); DateTime dateTime; for (int i = 0; i < count; i++) { dateTime = new(faker.Random.Int(1980, 2000), faker.Random.Int(1, 12), faker.Random.Int(1, 28)); var gender = faker.Person.Gender; Human person = new(faker.Name.FirstName(gender) + faker.Name.FullName(gender), dateTime, faker.Address.City(), 19999999, getHashCode); persons.Add(person); } }
private void CreatePersonDictionary(IGetHashCode getHashCode, int count) { Dictionary <Human, string> persons = new(); Faker faker = new("ru"); DateTime dateTime; for (int i = 0; i < count; i++) { dateTime = new(faker.Random.Int(1980, 2000), faker.Random.Int(1, 12), faker.Random.Int(1, 28)); var gender = faker.Person.Gender; Human human = new(faker.Name.FirstName(gender) + faker.Name.FullName(gender), dateTime, faker.Address.City(), 19999999, getHashCode); persons.Add(human, faker.Address.City()); } }
public Human(string fullName, DateTime date, string place, int passport, IGetHashCode getHashCode) { if (fullName == null) { throw new ArgumentNullException($"Значение {nameof(fullName)} не может быть {fullName}"); } if (passport < 1000000 && passport > 9999999) { throw new ArgumentOutOfRangeException($"Значение {nameof(passport)} не может быть {passport}"); } PlaceBirth = place ?? throw new ArgumentNullException($"Значение {nameof(place)} не может быть {place}"); NameSurnamePatronymic = GetFullName(fullName); DateBirth = date; Passport = passport; _getCode = getHashCode; }