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


C# JsonPatchDocument.Copy方法代码示例

本文整理汇总了C#中JsonPatchDocument.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# JsonPatchDocument.Copy方法的具体用法?C# JsonPatchDocument.Copy怎么用?C# JsonPatchDocument.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonPatchDocument的用法示例。


在下文中一共展示了JsonPatchDocument.Copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyFromListToEndOfList

        public void CopyFromListToEndOfList()
        {
            dynamic doc = new ExpandoObject();
            doc.IntegerList = new List<int>() { 1, 2, 3 };

            // create patch
            JsonPatchDocument patchDoc = new JsonPatchDocument();
            patchDoc.Copy("IntegerList/0", "IntegerList/-");

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
            deserialized.ApplyTo(doc);

            Assert.Equal(new List<int>() { 1, 2, 3, 1 }, doc.IntegerList);
        }
开发者ID:leloulight,项目名称:JsonPatch,代码行数:15,代码来源:CopyOperationTests.cs

示例2: Copy

        public void Copy()
        {
            dynamic doc = new ExpandoObject();

            doc.StringProperty = "A";
            doc.AnotherStringProperty = "B";

            JsonPatchDocument patchDoc = new JsonPatchDocument();
            patchDoc.Copy("StringProperty", "AnotherStringProperty");

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
            deserialized.ApplyTo(doc);

            Assert.Equal("A", doc.AnotherStringProperty);
        }
开发者ID:leloulight,项目名称:JsonPatch,代码行数:16,代码来源:CopyOperationTests.cs

示例3: NonGenericPatchDocToGenericMustSerialize

        public void NonGenericPatchDocToGenericMustSerialize()
        {
            var doc = new SimpleDTO()
            {
                StringProperty = "A",
                AnotherStringProperty = "B"
            };

            JsonPatchDocument patchDoc = new JsonPatchDocument();
            patchDoc.Copy("StringProperty", "AnotherStringProperty");

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTO>>(serialized);

            deserialized.ApplyTo(doc);

            Assert.Equal("A", doc.AnotherStringProperty);
        }
开发者ID:leloulight,项目名称:JsonPatch,代码行数:18,代码来源:PatchDocumentTests.cs

示例4: CopyFromListToNonList

        public void CopyFromListToNonList()
        {
            var doc = new SimpleDTO()
            {
                IntegerList = new List<int>() { 1, 2, 3 }
            };

            // create patch
            JsonPatchDocument patchDoc = new JsonPatchDocument();
            patchDoc.Copy("IntegerList/0", "IntegerValue");

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);

            deserialized.ApplyTo(doc);

            Assert.Equal(1, doc.IntegerValue);
        }
开发者ID:leloulight,项目名称:JsonPatch,代码行数:18,代码来源:CopyTypedOperationTests.cs

示例5: Copy

        public void Copy()
        {
            var doc = new SimpleDTO()
            {
                StringProperty = "A",
                AnotherStringProperty = "B"
            };

            // create patch
            JsonPatchDocument patchDoc = new JsonPatchDocument();
            patchDoc.Copy("StringProperty", "AnotherStringProperty");

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
            deserialized.ApplyTo(doc);

            Assert.Equal("A", doc.AnotherStringProperty);
        }
开发者ID:leloulight,项目名称:JsonPatch,代码行数:18,代码来源:CopyTypedOperationTests.cs

示例6: CopyFromListToNonList

        public void CopyFromListToNonList()
        {
            var doc = new SimpleDTOWithNestedDTO()
             {
                 SimpleDTO = new SimpleDTO()
            {
                IntegerList = new List<int>() { 1, 2, 3 }
            }
             };

            // create patch
            JsonPatchDocument<SimpleDTOWithNestedDTO> patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Copy<int>(o => o.SimpleDTO.IntegerList, 0, o => o.SimpleDTO.IntegerValue);

            patchDoc.ApplyTo(doc);

            Assert.Equal(1, doc.SimpleDTO.IntegerValue);
        }
开发者ID:Drakraq,项目名称:JsonPatch,代码行数:18,代码来源:ObjectAdapterTestsOnNested.cs

示例7: Copy

        public void Copy()
        {
            var doc = new SimpleDTOWithNestedDTO()
               {
                   SimpleDTO = new SimpleDTO()
             {
                 StringProperty = "A",
                 AnotherStringProperty = "B"
             }
               };

            // create patch
            JsonPatchDocument<SimpleDTOWithNestedDTO> patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Copy<string>(o => o.SimpleDTO.StringProperty, o => o.SimpleDTO.AnotherStringProperty);

            patchDoc.ApplyTo(doc);

            Assert.Equal("A", doc.SimpleDTO.AnotherStringProperty);

        }
开发者ID:Drakraq,项目名称:JsonPatch,代码行数:20,代码来源:ObjectAdapterTestsOnNested.cs

示例8: CopyWithSerialization

        public void CopyWithSerialization()
        {
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    StringProperty = "A",
                    AnotherStringProperty = "B"
                }
            };

            // create patch
            JsonPatchDocument<SimpleDTOWithNestedDTO> patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Copy<string>(o => o.SimpleDTO.StringProperty, o => o.SimpleDTO.AnotherStringProperty);

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized);

            deserialized.ApplyTo(doc);

            Assert.Equal("A", doc.SimpleDTO.AnotherStringProperty);

        }
开发者ID:Drakraq,项目名称:JsonPatch,代码行数:23,代码来源:ObjectAdapterTestsOnNested.cs

示例9: CopyFromNonListToListWithSerialization

        public void CopyFromNonListToListWithSerialization()
        {
            // Arrange
            var doc = new SimpleDTO()
            {
                IntegerValue = 5,
                IntegerList = new List<int>() { 1, 2, 3 }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTO>();
            patchDoc.Copy<int>(o => o.IntegerValue, o => o.IntegerList, 0);

            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTO>>(serialized);

            // Act
            deserialized.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 5, 1, 2, 3 }, doc.IntegerList);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:22,代码来源:ObjectAdapterTests.cs

示例10: CopyToEndOfList

        public void CopyToEndOfList()
        {
            // Arrange
            var doc = new SimpleDTO()
            {
                IntegerValue = 5,
                IntegerList = new List<int>() { 1, 2, 3 }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTO>();
            patchDoc.Copy<int>(o => o.IntegerValue, o => o.IntegerList);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 1, 2, 3, 5 }, doc.IntegerList);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:19,代码来源:ObjectAdapterTests.cs

示例11: CopyWithSerialization

        public void CopyWithSerialization()
        {
            // Arrange
            var doc = new SimpleDTO()
            {
                StringProperty = "A",
                AnotherStringProperty = "B"
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTO>();
            patchDoc.Copy<string>(o => o.StringProperty, o => o.AnotherStringProperty);
            var serialized = JsonConvert.SerializeObject(patchDoc);
            var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTO>>(serialized);

            // Act
            deserialized.ApplyTo(doc);

            // Assert
            Assert.Equal("A", doc.AnotherStringProperty);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:21,代码来源:ObjectAdapterTests.cs

示例12: CopyFromListToNonList

        public void CopyFromListToNonList()
        {
            // Arrange
            var doc = new SimpleDTO()
            {
                IntegerList = new List<int>() { 1, 2, 3 }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTO>();
            patchDoc.Copy<int>(o => o.IntegerList, 0, o => o.IntegerValue);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(1, doc.IntegerValue);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:18,代码来源:ObjectAdapterTests.cs

示例13: CopyFromNonListToList

        public void CopyFromNonListToList()
        {
            // Arrange
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
                {
                    IntegerValue = 5,
                    IntegerList = new List<int>() { 1, 2, 3 }
                }
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Copy<int>(o => o.SimpleDTO.IntegerValue, o => o.SimpleDTO.IntegerList, 0);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal(new List<int>() { 5, 1, 2, 3 }, doc.SimpleDTO.IntegerList);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:22,代码来源:NestedObjectTests.cs

示例14: Copy

        public void Copy()
        {
            // Arrange
            var doc = new SimpleDTO()
            {
                StringProperty = "A",
                AnotherStringProperty = "B"
            };

            // create patch
            var patchDoc = new JsonPatchDocument<SimpleDTO>();
            patchDoc.Copy<string>(o => o.StringProperty, o => o.AnotherStringProperty);

            // Act
            patchDoc.ApplyTo(doc);

            // Assert
            Assert.Equal("A", doc.AnotherStringProperty);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:19,代码来源:ObjectAdapterTests.cs

示例15: CopyToEndOfList

        public void CopyToEndOfList()
        {
            var doc = new SimpleDTOWithNestedDTO()
            {
                SimpleDTO = new SimpleDTO()
           {
               IntegerValue = 5,
               IntegerList = new List<int>() { 1, 2, 3 }
           }
            };

            // create patch
            JsonPatchDocument<SimpleDTOWithNestedDTO> patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
            patchDoc.Copy<int>(o => o.SimpleDTO.IntegerValue, o => o.SimpleDTO.IntegerList);

            patchDoc.ApplyTo(doc);


            Assert.Equal(new List<int>() { 1, 2, 3, 5 }, doc.SimpleDTO.IntegerList);

        }
开发者ID:Drakraq,项目名称:JsonPatch,代码行数:21,代码来源:ObjectAdapterTestsOnNested.cs


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