gpt4 book ai didi

c# - 我可以伪造国家吗(C#)

转载 作者:行者123 更新时间:2023-12-01 23:33:20 25 4
gpt4 key购买 nike

我刚刚开始使用 C# .net 5.0 中的 Bogus。我设法在沙盒应用程序中返回非常有用的数据,但我想将数据限制为基于美国。有没有办法做到这一点? (这是我的沙盒应用程序的一部分)

using Bogus;

namespace FrankenPeople
{
public class GetBogus
{
public enum Gender
{
Male,
Female
}

private static int userId = 1;

private static readonly Faker<Person> fakeData = new Faker<Person>()
.RuleFor(p => p.Id, f => userId++)
.RuleFor(p => p.Gender, f => f.PickRandom<Gender>().ToString())
.RuleFor(p => p.Title, f => f.Name.Prefix(f.Person.Gender))
.RuleFor(p => p.FirstName, f => f.Name.FirstName(f.Person.Gender))
.RuleFor(p => p.MiddleName, f => f.Name.FirstName(f.Person.Gender))
.RuleFor(p => p.LastName, f => f.Name.LastName(f.Person.Gender))
.RuleFor(p => p.StreetAddress, f => f.Address.StreetAddress())
.RuleFor(p => p.StreetName, f => f.Address.StreetName())
.RuleFor(p => p.City, f => f.Address.City())
.RuleFor(p => p.State, f => f.Address.State())
.RuleFor(p => p.Country, f => f.Address.Country())
.RuleFor(p => p.ZipCode, f => f.Address.ZipCode())
.RuleFor(p => p.Phone, f => f.Phone.PhoneNumber("(###)-###-####"))
.RuleFor(p => p.Email, (f, p) => f.Internet.Email(p.FirstName, p.LastName))
.RuleFor(p => p.SSN, f => f.Random.Replace("###-##-####"))
.RuleFor(p => p.DOB, f => f.Date.Past(18))
;
public static Faker<Person> FakeData => fakeData;
}
}

最佳答案

Using locales您可以获得地址、域后缀和电话号码:

var faker = new Faker("en_US");

关于c# - 我可以伪造国家吗(C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65943152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com