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


C# RavenJObject.CloneToken方法代码示例

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

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

示例1: SetCachedDocument

		public void SetCachedDocument(string key, Etag etag, RavenJObject doc, RavenJObject metadata, int size)
		{
			if (skipSettingDocumentInCache)
				return;

			var documentClone = ((RavenJObject)doc.CloneToken());
			documentClone.EnsureCannotBeChangeAndEnableSnapshotting();
			var metadataClone = ((RavenJObject)metadata.CloneToken());
			metadataClone.EnsureCannotBeChangeAndEnableSnapshotting();
			try
			{
				cachedSerializedDocuments.Set("Doc/" + key + "/" + etag, new CachedDocument
				{
					Document = documentClone,
					Metadata = metadataClone,
					Size = size
				}, new CacheItemPolicy
				{
					SlidingExpiration = configuration.MemoryCacheExpiration,
				});
			}
			catch (OverflowException)
			{
				// this is a bug in the framework
				// http://connect.microsoft.com/VisualStudio/feedback/details/735033/memorycache-set-fails-with-overflowexception-exception-when-key-is-u7337-u7f01-u2117-exception-message-negating-the-minimum-value-of-a-twos-complement-number-is-invalid 
				// in this case, we just threat it as uncachable
			}

		}
开发者ID:925coder,项目名称:ravendb,代码行数:29,代码来源:DocumentCacher.cs


示例2: SetCachedDocument

 public void SetCachedDocument(string key, Guid etag, RavenJObject doc, RavenJObject metadata)
 {
     cachedSerializedDocuments["Doc/" + key + "/" + etag] = new CachedDocument
     {
         Document = ((RavenJObject)doc.CloneToken()).EnsureSnapshot(),
         Metadata = ((RavenJObject)metadata.CloneToken()).EnsureSnapshot()
     };
 }
开发者ID:kblooie,项目名称:ravendb,代码行数:8,代码来源:DocumentCacher.cs


示例3: SetCachedDocument

        public void SetCachedDocument(string key, Guid etag, RavenJObject doc, RavenJObject metadata)
        {
        	var documentClone = ((RavenJObject)doc.CloneToken());
			documentClone.EnsureSnapshot();
        	var metadataClone = ((RavenJObject)metadata.CloneToken());
			metadataClone.EnsureSnapshot();
        	cachedSerializedDocuments["Doc/" + key + "/" + etag] = new CachedDocument
            {
                Document = documentClone,
                Metadata = metadataClone
            };
        }
开发者ID:stgwilli,项目名称:ravendb,代码行数:12,代码来源:DocumentCacher.cs


示例4: CloningTestsWorksCorrectly

		public void CloningTestsWorksCorrectly()
		{
			var f = new RavenJObject();
			f["1"] = new RavenJValue(1);
			f["2"] = new RavenJValue(2);

			var f1 = (RavenJObject)f.CloneToken();
			f1["2"] = new RavenJValue(3);

			var val = (RavenJValue) f["2"];
			Assert.Equal(2, val.Value);
			val = (RavenJValue)f1["2"];
			Assert.Equal(3, val.Value);

			var f2 = (RavenJObject)f1.CloneToken();
			val = (RavenJValue)f2["2"];
			Assert.Equal(3, val.Value);

			f["2"] = f2;
			f1 = (RavenJObject) f.CloneToken();
			f.Remove("2");
			Assert.Null(f["2"]);
			Assert.NotNull(f1["2"]);
		}
开发者ID:925coder,项目名称:ravendb,代码行数:24,代码来源:CloningTests.cs


示例5: SetCachedDocument

		public void SetCachedDocument(string key, Guid etag, RavenJObject doc, RavenJObject metadata)
		{
			if (skipSettingDocumentInCache)
				return;

			var documentClone = ((RavenJObject)doc.CloneToken());
			documentClone.EnsureSnapshot();
			var metadataClone = ((RavenJObject)metadata.CloneToken());
			metadataClone.EnsureSnapshot();
			cachedSerializedDocuments.Set("Doc/" + key + "/" + etag, new CachedDocument
			{
				Document = documentClone,
				Metadata = metadataClone
			}, new CacheItemPolicy
			{
				SlidingExpiration = TimeSpan.FromMinutes(5),
			});

		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:19,代码来源:DocumentCacher.cs


示例6: ShouldBehaveNicelyInMultithreaded

        public void ShouldBehaveNicelyInMultithreaded()
        {
            var obj = new RavenJObject
                        {
                            {"prop1", 2},
                            {"prop2", "123"}
                        };

            var copy = (RavenJObject)obj.CloneToken() ;
            copy["@id"] = "movies/1";

            Parallel.For(0, 10000, i =>
                                    {
                                        Assert.True(copy.ContainsKey("@id"));
                                        var foo = (RavenJObject)copy.CloneToken();
                                        Assert.True(foo.ContainsKey("@id"));
                                        Assert.True(copy.ContainsKey("@id"));
                                    });
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:19,代码来源:CloningTests.cs


示例7: ApplyPatch

        public PatchResultData ApplyPatch(string docId, Etag etag,
                                          PatchRequest[] patchExistingDoc, PatchRequest[] patchDefaultDoc, RavenJObject defaultMetadata,
                                          TransactionInformation transactionInformation, bool debugMode = false)
        {
            if (docId == null)
                throw new ArgumentNullException("docId");
            return ApplyPatchInternal(docId, etag, transactionInformation,
                                      jsonDoc => new JsonPatcher(jsonDoc.ToJson()).Apply(patchExistingDoc),
                                      () =>
                                      {
                                          if (patchDefaultDoc == null || patchDefaultDoc.Length == 0)
                                              return null;

                                          var jsonDoc = new RavenJObject();
                                          jsonDoc[Constants.Metadata] = defaultMetadata.CloneToken() ?? new RavenJObject();
                                          return new JsonPatcher(jsonDoc).Apply(patchDefaultDoc);
                                      },
                                      () => null, debugMode);
        }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:19,代码来源:PatchActions.cs


示例8: SetCachedDocument

		public void SetCachedDocument(string key, Guid etag, RavenJObject doc, RavenJObject metadata, int size)
		{
			if (skipSettingDocumentInCache)
				return;

			var documentClone = ((RavenJObject)doc.CloneToken());
			documentClone.EnsureSnapshot();
			var metadataClone = ((RavenJObject)metadata.CloneToken());
			metadataClone.EnsureSnapshot();
			cachedSerializedDocuments.Set("Doc/" + key + "/" + etag, new CachedDocument
			{
				Document = documentClone,
				Metadata = metadataClone,
				Size = size
			}, new CacheItemPolicy
			{
				SlidingExpiration = configuration.MemoryCacheExpiration,
			});

		}
开发者ID:jtmueller,项目名称:ravendb,代码行数:20,代码来源:DocumentCacher.cs


示例9: FileHeader

 public FileHeader( string key, RavenJObject metadata )
 {
     this.FullPath = key;            
     this.Metadata = metadata;
     this.OriginalMetadata = (RavenJObject)metadata.CloneToken();
     
     SetFileSize();
 }
开发者ID:GorelH,项目名称:ravendb,代码行数:8,代码来源:FileHeader.cs


示例10: ShouldNotFail

		public void ShouldNotFail()
		{
			var root = new RavenJObject();
			var current = root;
			for (int i = 0; i < 10000; i++)
			{
				var temp = new RavenJObject();
				current.Add("Inner", temp);
				current = temp;
			}

			var anotherRoot = (RavenJObject)root.CloneToken();
			do
			{
				anotherRoot["Inner"] = 0;
			} while ((anotherRoot = anotherRoot["Inner"] as RavenJObject) != null);
		}
开发者ID:925coder,项目名称:ravendb,代码行数:17,代码来源:CloningTests.cs


示例11: ApplyPatch

		public Tuple<PatchResultData, List<string>> ApplyPatch(string docId, Etag etag,
															   ScriptedPatchRequest patchExisting, ScriptedPatchRequest patchDefault, RavenJObject defaultMetadata,
															   TransactionInformation transactionInformation, bool debugMode = false)
		{
			ScriptedJsonPatcher scriptedJsonPatcher = null;
			DefaultScriptedJsonPatcherOperationScope scope = null;

			try
			{
				var applyPatchInternal = ApplyPatchInternal(docId, etag, transactionInformation,
					jsonDoc =>
					{
						scope = scope ?? new DefaultScriptedJsonPatcherOperationScope(Database, debugMode);
						scriptedJsonPatcher = new ScriptedJsonPatcher(Database);
						return scriptedJsonPatcher.Apply(scope, jsonDoc.ToJson(), patchExisting, jsonDoc.SerializedSizeOnDisk, jsonDoc.Key);
					},
					() =>
					{
						if (patchDefault == null)
							return null;

						scope = scope ?? new DefaultScriptedJsonPatcherOperationScope(Database, debugMode);

						scriptedJsonPatcher = new ScriptedJsonPatcher(Database);
						var jsonDoc = new RavenJObject();
						jsonDoc[Constants.Metadata] = defaultMetadata.CloneToken() ?? new RavenJObject();
						return scriptedJsonPatcher.Apply(scope, jsonDoc, patchDefault, 0, docId);
					},
					() =>
					{
						if (scope == null)
							return null;
						return scope
							.GetPutOperations()
							.ToList();
					},
					() =>
					{
						if (scope == null)
							return null;

						return scope.DebugActions;
					},
					debugMode);
				return Tuple.Create(applyPatchInternal, scriptedJsonPatcher == null ? new List<string>() : scriptedJsonPatcher.Debug);
			}
			finally
			{
				if (scope != null)
					scope.Dispose();
			}
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:52,代码来源:PatchActions.cs



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