本文整理汇总了C#中Person.CopyFields方法的典型用法代码示例。如果您正苦于以下问题:C# Person.CopyFields方法的具体用法?C# Person.CopyFields怎么用?C# Person.CopyFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person.CopyFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyFields_TypedRow_To_Extended
public void CopyFields_TypedRow_To_Extended()
{
var from = new Person
{
FirstName = "Ivan",
Amount = 10,
DOB = new DateTime(1990, 2, 16),
YearsWithCompany = null
};
var to = new ExtendedPerson
{
FirstName = "John",
Description = "descr",
YearsWithCompany = 30,
Info = "extended info",
Count = long.MaxValue
};
from.CopyFields(to);
Assert.AreEqual(to.FirstName, from.FirstName);
Assert.AreEqual(to.LastName, from.LastName);
Assert.AreEqual(to.Amount, from.Amount);
Assert.AreEqual(to.Classification, from.Classification);
Assert.AreEqual(to.Description, from.Description);
Assert.AreEqual(to.DOB, from.DOB);
Assert.AreEqual(to.GoodPerson, from.GoodPerson);
Assert.AreEqual(to.ID, from.ID);
Assert.AreEqual(to.LuckRatio, from.LuckRatio);
Assert.AreEqual(to.YearsInSpace, from.YearsInSpace);
Assert.AreEqual(to.YearsWithCompany, from.YearsWithCompany);
Assert.AreEqual("extended info", to.Info);
Assert.AreEqual(long.MaxValue, to.Count);
}
示例2: CopyFields_TypedRow_Filter
public void CopyFields_TypedRow_Filter()
{
var from = new Person
{
FirstName = "Ivan",
Amount = 10,
DOB = new DateTime(1990, 2, 16),
GoodPerson = true,
LuckRatio = 12345.6789D,
YearsInSpace = 20,
YearsWithCompany = null
};
var to = new Person
{
Description = "descr",
DOB = new DateTime(1980, 2, 16),
GoodPerson = false,
LuckRatio = 12345.6789D,
YearsWithCompany = 30
};
from.CopyFields(to, false, false, (n, f) => f.Name != "DOB" && f.Name != "GoodPerson" );
Assert.AreEqual(to.FirstName, from.FirstName);
Assert.AreEqual(to.LastName, from.LastName);
Assert.AreEqual(to.Amount, from.Amount);
Assert.AreEqual(to.Classification, from.Classification);
Assert.AreEqual(to.Description, from.Description);
Assert.AreEqual(new DateTime(1980, 2, 16), to.DOB);
Assert.AreEqual(false, to.GoodPerson);
Assert.AreEqual(to.ID, from.ID);
Assert.AreEqual(to.LuckRatio, from.LuckRatio);
Assert.AreEqual(to.YearsInSpace, from.YearsInSpace);
Assert.AreEqual(to.YearsWithCompany, from.YearsWithCompany);
}
示例3: CopyFields_TypedRow_To_Amorphous_NotIncludeAmorphous
public void CopyFields_TypedRow_To_Amorphous_NotIncludeAmorphous()
{
var from = new Person
{
FirstName = "Ivan",
LastName = "Petrov",
Amount = 10,
Classification = "class1",
YearsWithCompany = null
};
var to = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Empty)));
to.AmorphousData["field1"] = 123;
to.AmorphousData["FirstName"] = "John";
from.CopyFields(to, false);
Assert.AreEqual(0, to.Schema.FieldCount);
Assert.AreEqual(2, to.AmorphousData.Count);
Assert.AreEqual(123, to.AmorphousData["field1"]);
Assert.AreEqual("John", to.AmorphousData["FirstName"]);
}
示例4: CopyFields_TypedRow
public void CopyFields_TypedRow()
{
var from = new Person
{
FirstName = "Ivan",
LastName = "Petrov",
Amount = 10,
Classification = "class1",
Description = null,
DOB = new DateTime(1990, 2, 16),
GoodPerson = true,
ID = "abc",
LuckRatio = 12345.6789D,
YearsInSpace = 20,
YearsWithCompany = null
};
var to = new Person
{
Description = "descr",
YearsWithCompany = 30
};
from.CopyFields(to);
Assert.AreEqual(to.FirstName, from.FirstName);
Assert.AreEqual(to.LastName, from.LastName);
Assert.AreEqual(to.Amount, from.Amount);
Assert.AreEqual(to.Classification, from.Classification);
Assert.AreEqual(to.Description, from.Description);
Assert.AreEqual(to.DOB, from.DOB);
Assert.AreEqual(to.GoodPerson, from.GoodPerson);
Assert.AreEqual(to.ID, from.ID);
Assert.AreEqual(to.LuckRatio, from.LuckRatio);
Assert.AreEqual(to.YearsInSpace, from.YearsInSpace);
Assert.AreEqual(to.YearsWithCompany, from.YearsWithCompany);
}