本文整理汇总了C#中Person类的典型用法代码示例。如果您正苦于以下问题:C# Person类的具体用法?C# Person怎么用?C# Person使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Person类属于命名空间,在下文中一共展示了Person类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
/*
* Rules
*
* External entities are only mapped one way (either to or from)
* Data entities are mapped both ways
**/
AutoMapper.Mapper.AddProfile<MapperProfile>();
// External Entites
var addressExternalEntity = new AddressExternalEntity { Id = 1, Line1 = "Line1", Line2 = "Line2", Line3 = "Line3" };
AutoMapper.Mapper.Map<AddressExternalEntity, Address>(addressExternalEntity);
var personExternalEntity = new PersonExternalEntity {Id = 10, Name = "Bob"};
AutoMapper.Mapper.Map<PersonExternalEntity, Person>(personExternalEntity);
var personStatusResponse = new PersonStatusResponse {PersonId = 324};
AutoMapper.Mapper.Map<PersonStatusResponse, PersonStatusResponseExternalEntity>(personStatusResponse);
// Data Entities
var address = new Address { Id = 1, Line1 = "Line1", Line2 = "Line2", Line3 = "Line3" };
var addressDataEntity = AutoMapper.Mapper.Map<Address, AddressDataEntity>(address);
address = AutoMapper.Mapper.Map<AddressDataEntity, Address>(addressDataEntity);
var person = new Person { Id = 10, Name = "Bob" };
var personDataEntity = AutoMapper.Mapper.Map<Person, PersonDataEntity>(person);
person = AutoMapper.Mapper.Map<PersonDataEntity, Person>(personDataEntity);
Console.ReadKey();
}
示例2: AddAndGetPersonWithRegion
/// <summary>
/// Checks if a person with a region can be added and then retrieved from it.
/// </summary>
public void AddAndGetPersonWithRegion()
{
LightHouse.Core.Caching.DataCache dataCache = new LightHouse.Core.Caching.DataCache();
String id = Guid.NewGuid().ToString();
Person person = new Person()
{
ID = id,
Reference = "1671",
FirstName = new Localization.LocalString("Homer"),
LastName = new Localization.LocalString("Simpson"),
};
String region = "Family";
String falseRegion = "Acquaintances";
dataCache.Add(person.ID, person, region);
person.FirstName = new Localization.LocalString("Bart");
Person cachedPerson = dataCache.Get<Person>(id, region);
Person falsePerson = dataCache.Get<Person>(id, falseRegion);
Assert.NotNull(cachedPerson);
Assert.Null(falsePerson);
Assert.Equal(cachedPerson.FirstName.GetContent(), "Bart");
}
示例3: TestUpdate
public void TestUpdate()
{
var person = new Person { Name = "Bob", Age = 50 };
Connection
.Insert(person)
.Column(c => c.Name)
.Column(c => c.Age)
.ExecuteNonQuery();
var saved = Connection
.Select<Person>()
.Column(c => c.Name)
.Column(c => c.Age)
.Query()
.FirstOrDefault();
saved.Name = "John";
Connection
.Update(saved)
.Column(c => c.Name)
.Where(p => p.Name == "Bob")
.ExecuteNonQuery();
var updated = Connection
.Select<Person>()
.Column(c => c.Name)
.Column(c => c.Age)
.Query()
.FirstOrDefault();
Assert.AreEqual("John", updated.Name);
}
示例4: Example
public void Example()
{
#region Usage
Person person = new Person();
string jsonIncludeDefaultValues = JsonConvert.SerializeObject(person, Formatting.Indented);
Console.WriteLine(jsonIncludeDefaultValues);
// {
// "Name": null,
// "Age": 0,
// "Partner": null,
// "Salary": null
// }
string jsonIgnoreDefaultValues = JsonConvert.SerializeObject(person, Formatting.Indented, new JsonSerializerSettings
{
DefaultValueHandling = DefaultValueHandling.Ignore
});
Console.WriteLine(jsonIgnoreDefaultValues);
// {}
#endregion
Assert.AreEqual("{}", jsonIgnoreDefaultValues);
}
示例5: TestShortcutCreate
public void TestShortcutCreate()
{
string storeName = "TestShortcutCreate" + DateTime.Now.Ticks;
string aliceId;
using (var context = CreateEntityContext(storeName))
{
var sales = new Department(context) { Name = "Sales", DeptId = 1 };
var bob = new Person(context) { Name = "Bob" };
var alice = new Person(context) { Name = "Alice", Age = 54, Department = sales, Friends = new Collection<IPerson> { bob } };
context.SaveChanges();
aliceId = alice.Id;
}
using (var context = CreateEntityContext(storeName))
{
var alice = context.Persons.FirstOrDefault(x => x.Id == aliceId);
Assert.IsNotNull(alice);
Assert.AreEqual("Alice", alice.Name);
Assert.AreEqual(54, alice.Age);
Assert.IsNotNull(alice.Department);
Assert.AreEqual("Sales", alice.Department.Name);
Assert.AreEqual(1, alice.Friends.Count);
Assert.AreEqual("Bob", alice.Friends.First().Name);
}
}
示例6: RetrieveCommitmentsForDisaster
public IQueryable<Commitment> RetrieveCommitmentsForDisaster(Person person, Disaster disaster)
{
if (disaster == null)
throw new ArgumentNullException("disaster", "Disaster cannot be null");
return RetrieveCommitments(person, true).Where(c => c.DisasterId == disaster.Id);
}
示例7: BuildPersonFromDataBaseData
public static TestPerson BuildPersonFromDataBaseData(string idPerson, string MIS)
{
using (NpgsqlConnection connection = Global.GetSqlConnection())
{
string findPatient = "SELECT * FROM public.person WHERE id_person = '" + idPerson + "'";
NpgsqlCommand person = new NpgsqlCommand(findPatient, connection);
using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
{
Person p = new Person();
while (personFromDataBase.Read())
{
//что делать с DateSpecified и Мисами?
if (personFromDataBase["birthday"]!= DBNull.Value)
p.BirthDate = Convert.ToDateTime(personFromDataBase["birthday"]);
if (MIS == "")
p.IdPatientMis = null;
if ((personFromDataBase["family_name"] != DBNull.Value) || (personFromDataBase["given_name"] != DBNull.Value) || (personFromDataBase["middle_name"] != DBNull.Value))
{
p.HumanName = new HumanName();
if (personFromDataBase["family_name"] != DBNull.Value)
p.HumanName.FamilyName = Convert.ToString(personFromDataBase["family_name"]);
if (personFromDataBase["given_name"] != DBNull.Value)
p.HumanName.GivenName = Convert.ToString(personFromDataBase["given_name"]);
if (personFromDataBase["middle_name"] != DBNull.Value)
p.HumanName.MiddleName = Convert.ToString(personFromDataBase["middle_name"]);
}
TestPerson pers = new TestPerson(p);
if (personFromDataBase["id_sex"] != DBNull.Value)
pers.sex = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_sex"]));
return pers;
}
}
}
return null;
}
示例8: GetLine
protected string GetLine(int id, Person p, string colSep, string rowSep, bool incRowSep, bool incDOB, bool incAddresses, bool incPhoneNbrs, bool incRefInfo)
{
string result = string.Empty;
if (incRowSep)
result += rowSep;
result += id.ToString() + colSep + p.Firstname + colSep + p.Middlename + colSep + p.Surname;
if (incDOB)
result += colSep + (p.Dob == DateTime.MinValue ? "" : p.Dob.ToString("dd-MM-yyyy"));
if (incAddresses)
result += colSep + GetAddresses(p.EntityID);
if (incPhoneNbrs)
result += colSep + GetPhoneNbrs(p.EntityID);
if (incRefInfo)
{
string orgNames = string.Empty;
string provNbrs = string.Empty;
System.Data.DataTable tbl = RegisterReferrerDB.GetDataTable_OrganisationsOf(id);
RegisterReferrer[] list = new RegisterReferrer[tbl.Rows.Count];
for(int i=0; i<tbl.Rows.Count; i++)
{
list[i] = RegisterReferrerDB.Load(tbl.Rows[i]);
list[i].Organisation = OrganisationDB.Load(tbl.Rows[i], "", "organisation_entity_id", "organisation_is_deleted");
orgNames += (orgNames.Length == 0 ? "" : "\r\n") + list[i].Organisation.Name;
provNbrs += (provNbrs.Length == 0 ? "" : "\r\n") + list[i].ProviderNumber;
}
result += colSep + orgNames;
result += colSep + provNbrs;
}
return result;
}
示例9: TestCase2
public void TestCase2()
{
// test case 2 data setup
// wallet 1 credit cards
List<string> creditCardList1 = new List<string>();
creditCardList1.Add("Visa");
creditCardList1.Add("Discover");
// wallet 2 credit cards
List<string> creditCardList2 = new List<string>();
creditCardList2.Add("MasterCard");
Person personB = new Person();
Wallet wallet1 = new Wallet(creditCardList1);
personB.addWallet(wallet1);
Assert.AreEqual(11, wallet1.getTotalInterest());
Wallet wallet2 = new Wallet(creditCardList2);
personB.addWallet(wallet2);
Assert.AreEqual(5, wallet2.getTotalInterest());
Assert.AreEqual(16, personB.getTotalInterestPerPerson());
}
示例10: TestCase3
public void TestCase3()
{
// test case 3 data setup
// wallet 3 credit cards
List<string> creditCardList3 = new List<string>();
creditCardList3.Add("MasterCard");
creditCardList3.Add("Visa");
// wallet 4 credit cards
List<string> creditCardList4 = new List<string>();
creditCardList4.Add("Visa");
creditCardList4.Add("MasterCard");
Person personC = new Person();
Wallet wallet3 = new Wallet(creditCardList3);
personC.addWallet(wallet3);
Assert.AreEqual(15, personC.getTotalInterestPerPerson());
Person personD = new Person();
Wallet wallet4 = new Wallet(creditCardList4);
personD.addWallet(wallet4);
Assert.AreEqual(15, personD.getTotalInterestPerPerson());
}
示例11: Create
public void Create(Person person)
{
t_person entity = new t_person();
entity.UpdateEntity(person);
_sqlRepository.Insert(entity);
person.PersonId = entity.PersonId;
}
示例12: OnLogin
/// <summary>
/// Обработчик аутентификации пользователя.
/// </summary>
protected virtual void OnLogin(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(logIn.UserName) || HttpContext.Current == null)
return;
Person currentUser = new Person(HttpContext.Current.User.Identity);
if (!currentUser.LoadByDomainName(logIn.UserName))
return;
if (!currentUser.IsInRole(RolesEnum.PublicUser))
{
logIn.FailureText = "User cant work with the public portal.";
return;
}
IList<PersonAttribute> attributes =
PersonAttributes.GetPersonAttributesByKeyword(currentUser.ID.Value
, PersonAttributeTypes.PublicPassword.ToString());
if (logIn.Password == (string)attributes[0].Value)
{
Session["UserID"] = currentUser.ID.Value;
FormsAuthentication.RedirectFromLoginPage(logIn.UserName, logIn.RememberMeSet);
}
logIn.FailureText = "Incorrect information.";
}
示例13: TestOneToOneRecursiveInsertAsync
public async void TestOneToOneRecursiveInsertAsync() {
var conn = Utils.CreateAsyncConnection();
await conn.DropTableAsync<Passport>();
await conn.DropTableAsync<Person>();
await conn.CreateTableAsync<Passport>();
await conn.CreateTableAsync<Person>();
var person = new Person
{
Name = "John",
Surname = "Smith",
Passport = new Passport {
PassportNumber = "JS123456"
}
};
// Insert the elements in the database recursively
await conn.InsertWithChildrenAsync(person, recursive: true);
var obtainedPerson = await conn.FindAsync<Person>(person.Identifier);
var obtainedPassport = await conn.FindAsync<Passport>(person.Passport.Id);
Assert.NotNull(obtainedPerson);
Assert.NotNull(obtainedPassport);
Assert.That(obtainedPerson.Name, Is.EqualTo(person.Name));
Assert.That(obtainedPerson.Surname, Is.EqualTo(person.Surname));
Assert.That(obtainedPassport.PassportNumber, Is.EqualTo(person.Passport.PassportNumber));
Assert.That(obtainedPassport.OwnerId, Is.EqualTo(person.Identifier));
}
示例14: Example
public void Example()
{
#region Usage
Person person = new Person
{
Name = "Nigal Newborn",
Age = 1
};
string jsonIncludeNullValues = JsonConvert.SerializeObject(person, Formatting.Indented);
Console.WriteLine(jsonIncludeNullValues);
// {
// "Name": "Nigal Newborn",
// "Age": 1,
// "Partner": null,
// "Salary": null
// }
string jsonIgnoreNullValues = JsonConvert.SerializeObject(person, Formatting.Indented, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
Console.WriteLine(jsonIgnoreNullValues);
// {
// "Name": "Nigal Newborn",
// "Age": 1
// }
#endregion
}
示例15: GroupAdd
public void GroupAdd()
{
Group group = new Group();
string name1 = "maichao";
string company1 = "ynu";
string position1 = "student";
Person person1 = new Person { Name = name1, Company = company1, Position = position1 };
group.AddPerson(person1);
Assert.AreEqual(1, group.Amount);
string name2 = "mai";
string company2 = "ynu";
string position2 = "graduate";
Person person2 = new Person { Name = name2, Company = company2, Position = position2 };
group.AddPerson(person2);
Assert.AreEqual(2, group.Amount);
Assert.AreNotEqual(group.Persons[0], group.Persons[1]);
}