当前位置: 首页>>代码示例>>C#>>正文


C# ChangeSet.ApplyChanges方法代码示例

本文整理汇总了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));
        }
开发者ID:chrisblock,项目名称:Changes,代码行数:28,代码来源:ChangeSetTests.cs

示例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));
        }
开发者ID:chrisblock,项目名称:Changes,代码行数:31,代码来源:ChangeSetTests.cs

示例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;
        }
开发者ID:chrisblock,项目名称:LinqToRest,代码行数:17,代码来源:TestObjectController.cs


注:本文中的ChangeSet.ApplyChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。