• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Json.JsonPatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Raven.Database.Json.JsonPatcher的典型用法代码示例。如果您正苦于以下问题:C# JsonPatcher类的具体用法?C# JsonPatcher怎么用?C# JsonPatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonPatcher类属于Raven.Database.Json命名空间,在下文中一共展示了JsonPatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PropertyAddition_WithConcurrenty_ExistingValueOn_Ok

 public void PropertyAddition_WithConcurrenty_ExistingValueOn_Ok()
 {
     JObject apply = new JsonPatcher(doc).Apply(
         JArray.Parse(@"[{  ""type"":""set"",""name"": ""body"", ""value"": ""differnt markup"", ""prevVal"": ""html markup"" }]")
         );
     Assert.Equal(@"{""title"":""A Blog Post"",""body"":""differnt markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}", apply.ToString(Formatting.None));
 }
开发者ID:torkelo,项目名称:ravendb,代码行数:7,代码来源:SimplePatchApplication.cs


示例2: PropertyIncrement

        public void PropertyIncrement()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                new[]
        		{
        			new PatchRequest
        			{
        				Type = PatchCommandType.Set,
        				Name = "blog_id",
        				Value = new JValue(1)
        			},
        		});

            patchedDoc = new JsonPatcher(patchedDoc).Apply(
                new[]
        		{
        			new PatchRequest
        			{
        				Type = PatchCommandType.Inc,
        				Name = "blog_id",
        				Value = new JValue(1)
        			},
        		});

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}],""blog_id"":2}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:Rationalle,项目名称:ravendb,代码行数:27,代码来源:SimplePatchApplication.cs


示例3: PropertyRemovalPropertyDoesNotExists

        public void PropertyRemovalPropertyDoesNotExists()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                JArray.Parse(@"[{ ""type"": ""unset"", ""name"": ""ip"" }]")
                );

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}", patchedDoc.ToString(Formatting.None));
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:8,代码来源:SimplePatchApplication.cs


示例4: AddingItemToArray_WithConcurrency_Ok

        public void AddingItemToArray_WithConcurrency_Ok()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                JArray.Parse(@"[{ ""type"": ""add"" , ""name"": ""comments"", ""value"": {""author"":""oren"",""text"":""agreed""}, ""prevVal"": [{""author"":""ayende"",""text"":""good post 1""},{author: ""ayende"", text:""good post 2""}] }]")
                );

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""},{""author"":""oren"",""text"":""agreed""}]}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:9,代码来源:ArrayPatching.cs


示例5: AddingItemToArrayWhenArrayDoesNotExists_WithConcurrency_Ok

        public void AddingItemToArrayWhenArrayDoesNotExists_WithConcurrency_Ok()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                JArray.Parse(@"[{ ""type"":""add"",  ""name"": ""blog_id"", ""value"": 1, ""prevVal"": undefined }]")
                );

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""blog_id"":[1]}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:9,代码来源:ArrayPatching.cs


示例6: PropertyAddition_WithConcurrenty_MissingProp

        public void PropertyAddition_WithConcurrenty_MissingProp()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                JArray.Parse(@"[{  ""type"":""set"",""name"": ""blog_id"", ""value"": 1, ""prevVal"": undefined }]")
                );

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}],""blog_id"":1}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:9,代码来源:SimplePatchApplication.cs


示例7: SetValueNestedInArray

        public void SetValueNestedInArray()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                JArray.Parse(
                    @"[{ ""type"": ""modify"",  ""name"": ""comments"", ""position"": 1, ""value"": [{ ""type"":""set"",""name"":""author"",""value"":""oren""} ]}]")
                );

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""oren"",""text"":""good post 2""}],""user"":{""name"":""ayende"",""id"":13}}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:10,代码来源:NestedPatching.cs


示例8: PropertyCopyNonExistingProperty

		public void PropertyCopyNonExistingProperty()
		{
			var patchedDoc = new JsonPatcher(doc).Apply(
				new[]
				{
					new PatchRequest
					{
						Type = PatchCommandType.Copy,
						Name = "non-existing",
						Value = new RavenJValue("irrelevant")
					},
				});

			Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}",
				patchedDoc.ToString(Formatting.None));
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:16,代码来源:SimplePatchApplication.cs


示例9: AddingItemToArrayWhenArrayDoesNotExists

        public void AddingItemToArrayWhenArrayDoesNotExists()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
				new[]
        		{
        			new PatchRequest
        			{
        				Type = PatchCommandType.Add,
        				Name = "blog_id",
        				Value = new JValue(1),
        			}
        		});

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""blog_id"":[1]}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:Rationalle,项目名称:ravendb,代码行数:16,代码来源:ArrayPatching.cs


示例10: PropertyMove

		public void PropertyMove()
		{
			var patchedDoc = new JsonPatcher(doc).Apply(
				new[]
        		{
        			new PatchRequest
        			{
        				Type = PatchCommandType.Rename,
        				Name = "comments",
        				Value = new JValue("cmts")
        			},
        		});

			Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""cmts"":[{""author"":""ayende"",""text"":""good post""}]}",
				patchedDoc.ToString(Formatting.None));
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:16,代码来源:SimplePatchApplication.cs


示例11: PropertyAddition_WithConcurrenty_ExistingValueOn_Ok

        public void PropertyAddition_WithConcurrenty_ExistingValueOn_Ok()
        {
            JObject apply = new JsonPatcher(doc).Apply(
                new[]
                {
                    new PatchRequest
                    {
                        Type = "set",
                        Name = "body",
                        Value = new JValue("differnt markup"),
                        PrevVal = new JValue("html markup")
                    },
                });

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""differnt markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}", apply.ToString(Formatting.None));
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:16,代码来源:SimplePatchApplication.cs


示例12: ExistingPropertySetToArray

        public void ExistingPropertySetToArray()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                new[]
                {
                    new PatchRequest
                    {
                        Type = PatchCommandType.Set,
                        Name = "title",
                        Value = new RavenJArray()
                    },
                });

            Assert.Equal(@"{""title"":[],""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:16,代码来源:SimplePatchApplication.cs


示例13: AddingEmptyObject

		public void AddingEmptyObject()
		{
			var patchedDoc = new JsonPatcher(doc).Apply(
				new[]
				{
					new PatchRequest
					{
						Type = PatchCommandType.Set,
						Name = "NewProp",
						Value = new RavenJObject()

					}
				});

			Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""NewProp"":{}}",
				patchedDoc.ToString(Formatting.None));
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:17,代码来源:ArrayPatching.cs


示例14: AddingItemToArray

        public void AddingItemToArray()
        {
        	var patchedDoc = new JsonPatcher(doc).Apply(
        		new[]
        		{
        			new PatchRequest
        			{
        				Type = PatchCommandType.Add,
        				Name = "comments",
        				Value = RavenJObject.Parse(@"{""author"":""oren"",""text"":""agreed""}")

        			}
        		});

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""},{""author"":""oren"",""text"":""agreed""}]}", 
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:nzdunic,项目名称:ravendb,代码行数:17,代码来源:ArrayPatching.cs


示例15: SetValueInNestedElement

		public void SetValueInNestedElement()
		{
			var patchedDoc = new JsonPatcher(doc).Apply(
				new[]
				{
					new PatchRequest
					{
						Type = PatchCommandType.Modify,
						Name = "user",
						Nested = new[]
						{
							new PatchRequest {Type = PatchCommandType.Set, Name = "name", Value = new RavenJValue("rahien")},
						}
					},
				});

            Assert.Equal(RavenJToken.Parse(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""user"":{""name"":""rahien"",""id"":13}}"),
				patchedDoc,new RavenJTokenEqualityComparer());
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:19,代码来源:NestedPatching.cs


示例16: SetValueInNestedElement

        public void SetValueInNestedElement()
        {
        	var patchedDoc = new JsonPatcher(doc).Apply(
        		new[]
        		{
        			new PatchRequest
        			{
        				Type = PatchCommandType.Modify,
        				Name = "user",
        				Nested = new[]
        				{
        					new PatchRequest {Type = PatchCommandType.Set, Name = "name", Value = new JValue("rahien")},
        				}
        			},
        		});

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""user"":{""name"":""rahien"",""id"":13}}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:philiphoy,项目名称:ravendb,代码行数:19,代码来源:NestedPatching.cs


示例17: RemoveValueInNestedElement

        public void RemoveValueInNestedElement()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                new[]
                {
                    new PatchRequest
                    {
                        Type = PatchCommandType.Modify,
                        Name = "user",
                        PrevVal = RavenJObject.Parse(@"{ ""name"": ""ayende"", ""id"": 13}"),
                        Nested = new[]
                        {
                            new PatchRequest {Type = PatchCommandType.Unset, Name = "name" },
                        }
                    },
                });

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""user"":{""id"":13}}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:20,代码来源:NestedPatching.cs


示例18: RenameAllItemsInArray

        public void RenameAllItemsInArray()
        {
            var patchedDoc = new JsonPatcher(doc).Apply(
                new[]
                    {
                        new PatchRequest
                            {
                                Type = PatchCommandType.Modify,
                                Name = "comments",
                                AllPositions = true,
        				Nested = new[]
        				{
        					new PatchRequest {Type = PatchCommandType.Rename, Name = "author", Value = "authorname"},
        				}
        			},
        		});

            Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""text"":""good post 1"",""authorname"":""ayende""},{""text"":""good post 2"",""authorname"":""ayende""}],""user"":{""name"":""ayende"",""id"":13}}",
                patchedDoc.ToString(Formatting.None));
        }
开发者ID:philiphoy,项目名称:ravendb,代码行数:20,代码来源:NestedPatching.cs


示例19: PropertyAddition_WithConcurrently_MissingProp

		public void PropertyAddition_WithConcurrently_MissingProp()
		{
			var patchedDoc = new JsonPatcher(doc).Apply(
			   new[]
				{
					new PatchRequest
					{
						Type = PatchCommandType.Set,
						Name = "blog_id",
						Value = new RavenJValue(1),
						PrevVal = RavenJObject.Parse("{'a': undefined}")["a"]
					},
				});

			Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}],""blog_id"":1}",
				patchedDoc.ToString(Formatting.None));
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:17,代码来源:SimplePatchApplication.cs


示例20: SimplePatching


//.........这里部分代码省略.........
                    "blogposts/1234",
                    new[]
                        {
                            new PatchRequest
                                {
                                    Type = PatchCommandType.Rename,
                                    Name = "Comments",
                                    Value = new RavenJValue("cmts")
                                }
                        });

                #endregion

                #region patching4
                // Assuming we have a Views counter in our entity
                documentStore.DatabaseCommands.Patch(
                    "blogposts/1234",
                    new[]
                        {
                            new PatchRequest
                                {
                                    Type = PatchCommandType.Inc,
                                    Name = "Views",
                                    Value = new RavenJValue(1)
                                }
                        });

                #endregion

                #region patching_arrays1
                // Append a new comment; Insert operation is supported
                // as well, by using PatchCommandType.Add and
                // specifying a Position to insert at
                documentStore.DatabaseCommands.Patch(
                    "blogposts/1234",
                    new[]
                        {
                            new PatchRequest
                                {
                                    Type = PatchCommandType.Add,
                                    Name = "Comments",
                                    Value =
                                        RavenJObject.FromObject(new BlogComment
                                                                    {Content = "FooBar"})
                                }
                        });

                // Remove the first comment
                documentStore.DatabaseCommands.Patch(
                    "blogposts/1234",
                    new[]
                        {
                            new PatchRequest
                                {
                                    Type = PatchCommandType.Remove,
                                    Name = "Comments",
                                    Position = 0
                                }
                        });

                #endregion

                var doc = new RavenJObject();

                #region nested1
                var addToPatchedDoc = new JsonPatcher(doc).Apply(
                    new[]
                {
                    new PatchRequest
                    {
                        Type = PatchCommandType.Modify,
                        Name = "user",
                        Nested = new[]
                        {
                            new PatchRequest {Type = PatchCommandType.Set, Name = "name", Value = new RavenJValue("rahien")},
                        }
                    },
                });

                #endregion

                #region nested2
                var removeFromPatchedDoc = new JsonPatcher(doc).Apply(
                new[]
                {
                    new PatchRequest
                    {
                        Type = PatchCommandType.Modify,
                        Name = "user",
                        PrevVal = RavenJObject.Parse(@"{ ""name"": ""ayende"", ""id"": 13}"),
                        Nested = new[]
                        {
                            new PatchRequest {Type = PatchCommandType.Unset, Name = "name" },
                        }
                    },
                });

                #endregion
            }
        }
开发者ID:sainiuc,项目名称:docs,代码行数:101,代码来源:PartialDocumentUpdates.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.RockTextBox类代码示例发布时间:2022-05-26
下一篇:
C# Qyoto.QVariant类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap