本文整理汇总了C#中ChangeSet.ApplyChanges方法的典型用法代码示例。如果您正苦于以下问题:C# ChangeSet.ApplyChanges方法的具体用法?C# ChangeSet.ApplyChanges怎么用?C# ChangeSet.ApplyChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChangeSet
的用法示例。
在下文中一共展示了ChangeSet.ApplyChanges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyChanges_EnumPropertyOnTypeChanged_PropertyInChangeSetIsChanged
public void ApplyChanges_EnumPropertyOnTypeChanged_PropertyInChangeSetIsChanged()
{
const TestEnum testEnumValue = TestEnum.ValueOne;
const int testIntegerValue = 42;
const string testStringValue = "The quick brown fox jumped over the lazy dog.";
var testIntegerEnumeration = new[] { 1, 2, 3, 4, 5 };
const TestEnum changedEnumValue = TestEnum.ValueTwo;
var testObject = new TestObject
{
TestEnum = testEnumValue,
TestInteger = testIntegerValue,
TestString = testStringValue,
TestIntegerEnumeration = testIntegerEnumeration
};
dynamic changeSet = new ChangeSet<TestObject>();
changeSet.TestEnum = changedEnumValue;
changeSet.ApplyChanges(ref testObject);
Assert.That(testObject, Is.Not.Null);
Assert.That(testObject.TestEnum, Is.EqualTo(changedEnumValue));
Assert.That(testObject.TestInteger, Is.EqualTo(testIntegerValue));
Assert.That(testObject.TestString, Is.EqualTo(testStringValue));
}
示例2: ApplyChanges_ChildrenOnTypeChanged_PropertyInChangeSetIsChanged
public void ApplyChanges_ChildrenOnTypeChanged_PropertyInChangeSetIsChanged()
{
const TestEnum testEnumValue = TestEnum.ValueOne;
const int testIntegerValue = 42;
const string testStringValue = "The quick brown fox jumped over the lazy dog.";
var testChildren = new[]
{
new TestObject()
};
var testObject = new TestObject
{
TestEnum = testEnumValue,
TestInteger = testIntegerValue,
TestString = testStringValue,
Children = new TestObject[0]
};
dynamic changeSet = new ChangeSet<TestObject>();
changeSet.Children = testChildren;
changeSet.ApplyChanges(ref testObject);
Assert.That(testObject, Is.Not.Null);
Assert.That(testObject.TestEnum, Is.EqualTo(testEnumValue));
Assert.That(testObject.TestInteger, Is.EqualTo(testIntegerValue));
Assert.That(testObject.TestString, Is.EqualTo(testStringValue));
Assert.That(testObject.Children, Is.EquivalentTo(testChildren));
}
示例3: Put
public IHttpActionResult Put(int id, ChangeSet<TestObject> changeSet)
{
var item = _repository.Get(id);
IHttpActionResult result = Ok();
if (item != null)
{
changeSet.ApplyChanges(ref item);
}
else
{
result = NotFound();
}
return result;
}