本文整理汇总了C#中Person类的典型用法代码示例。如果您正苦于以下问题:C# Person类的具体用法?C# Person怎么用?C# Person使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Person类属于命名空间,在下文中一共展示了Person类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:odw1,项目名称:Random-Stuff,代码行数:32,代码来源:Program.cs
示例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");
}
开发者ID:PongpetTurneo,项目名称:LightHouse,代码行数:31,代码来源:DataCache.cs
示例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);
}
开发者ID:flipbit,项目名称:syntax,代码行数:34,代码来源:DataTests.cs
示例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);
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:26,代码来源:DefaultValueHandlingIgnore.cs
示例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);
}
}
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:25,代码来源:SimpleContextTests.cs
示例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);
}
开发者ID:jmoch01,项目名称:crisischeckin,代码行数:7,代码来源:VolunteerService.cs
示例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;
}
开发者ID:nbIxMaN,项目名称:MQTESTS,代码行数:35,代码来源:TestPerson.cs
示例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;
}
开发者ID:nblaurenciana-md,项目名称:Websites,代码行数:35,代码来源:AjaxDuplicatePersonList.aspx.cs
示例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());
}
开发者ID:shuyichen,项目名称:CreditCardInterest,代码行数:25,代码来源:CreditCardTest.cs
示例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());
}
开发者ID:shuyichen,项目名称:CreditCardInterest,代码行数:25,代码来源:CreditCardTest.cs
示例11: Create
public void Create(Person person)
{
t_person entity = new t_person();
entity.UpdateEntity(person);
_sqlRepository.Insert(entity);
person.PersonId = entity.PersonId;
}
开发者ID:magnusfrodell,项目名称:ShootingRange,代码行数:7,代码来源:PersonDataStore.cs
示例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.";
}
开发者ID:Confirmit,项目名称:Portal,代码行数:29,代码来源:LoginPage.aspx.cs
示例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));
}
开发者ID:xamarin-libraries,项目名称:sqlite.net-pcl-extensions,代码行数:29,代码来源:RecursiveWriteAsyncTests.cs
示例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
}
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:31,代码来源:NullValueHandlingIgnore.cs
示例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]);
}
开发者ID:ChaoMai,项目名称:learning,代码行数:26,代码来源:UnitTestDomainGroup.cs
示例16: Add
public void Add()
{
Person person = new Person(auth, clientId);
try
{
PersonDetails personDetails = new PersonDetails
{
EmailAddress = "[email protected]",
Name = "test",
AccessLevel = 1023,
Password = "somepassword"
};
person.Add(personDetails);
}
catch (CreatesendException ex)
{
ErrorResult error = (ErrorResult)ex.Data["ErrorResult"];
Console.WriteLine(error.Code);
Console.WriteLine(error.Message);
}
catch (Exception ex)
{
// Handle some other failure
Console.WriteLine(ex.ToString());
}
}
开发者ID:abitgone,项目名称:createsend-dotnet,代码行数:28,代码来源:People.cs
示例17: Serialize
public void Serialize()
{
var serializer = new NewtonsoftJSONSerializer();
var p = new Person { Name = "Json", Age = 23};
Assert.AreEqual("{\"Name\":\"Json\",\"Age\":23}", serializer.Serialize(p));
}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:7,代码来源:NewtonsoftJSONSerializerTestCase.cs
示例18: ShouldWork
public void ShouldWork()
{
using (var session = store.OpenSession())
{
var person = new Person
{
Id = "people/1",
Name = "Person 1",
Roles = new List<string>(),
Permissions = new List<OperationPermission>()
};
session.Store(person);
person.Permissions.Add(new OperationPermission()
{
Operation = "resources",
Allow = true,
Tags = {person.Id}
});
person = new Person
{
Id = "people/2",
Name = "Person 2",
Roles = new List<string>(),
Permissions = new List<OperationPermission>()
};
session.Store(person);
person.Permissions.Add(new OperationPermission()
{
Operation = "resources",
Allow = true,
Tags = {person.Id}
});
var resource = new Resource
{
Name = "resources",
Id = "resources/1"
};
session.Store(resource);
session.SetAuthorizationFor(resource, new DocumentAuthorization()
{
Tags = {"people/1"}
});
session.SaveChanges();
}
using (var session = store.OpenSession())
{
session.SecureFor("people/1", "resources/view");
session.Load<Resource>("resources/1");
var collection = session.Query<Resource>().ToList();
Assert.NotEmpty(collection);
}
using(var session = store.OpenSession())
{
session.SecureFor("people/2", "resources/view");
Assert.Throws<ReadVetoException>(() => session.Load<Resource>("resources/1"));
var collection = session.Query<Resource>().ToList();
Assert.Empty(collection);
}
}
开发者ID:925coder,项目名称:ravendb,代码行数:60,代码来源:fampinheiro.cs
示例19: Example
public void Example()
{
#region Usage
Person person = new Person
{
FirstName = "Dennis",
LastName = "Deepwater-Diver"
};
string startingWithF = JsonConvert.SerializeObject(person, Formatting.Indented,
new JsonSerializerSettings { ContractResolver = new DynamicContractResolver('F') });
Console.WriteLine(startingWithF);
// {
// "FirstName": "Dennis",
// "FullName": "Dennis Deepwater-Diver"
// }
string startingWithL = JsonConvert.SerializeObject(person, Formatting.Indented,
new JsonSerializerSettings { ContractResolver = new DynamicContractResolver('L') });
Console.WriteLine(startingWithL);
// {
// "LastName": "Deepwater-Diver"
// }
#endregion
}
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:27,代码来源:CustomContractResolver.cs
示例20: PersonViewModel
/// <summary>
/// Initializes a new instance of the <see cref="PersonViewModel"/> class.
/// </summary>
/// <param name="person">The person.</param>
public PersonViewModel(Person person)
{
Person = person ?? new Person();
GenerateData = new Command<object, object>(OnGenerateDataExecute, OnGenerateDataCanExecute);
ToggleCustomError = new Command<object>(OnToggleCustomErrorExecute);
}
开发者ID:BartekDuszynski,项目名称:Catel.Examples,代码行数:11,代码来源:PersonViewModel.cs
注:本文中的Person类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论