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


C# Data.JsonDocument类代码示例

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


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

示例1: TryResolve

        public override bool TryResolve(
            string id,
            RavenJObject metadata,
            RavenJObject document,
            JsonDocument existingDoc)
        {
            if (id.StartsWith("Raven/", StringComparison.OrdinalIgnoreCase) &&
                !id.StartsWith("Raven/Hilo/", StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            try
            {
                this.ResolveConflict(id, metadata, document, existingDoc);
            }
            catch (Exception exception)
            {
                this.log.ErrorException(
                    string.Format(
                        "An exception occured while attempting to resolve a replication conflict for document '{0}'. The incoming document will be saved.",
                        id),
                    exception);
            }

            return true;
        }
开发者ID:paulkearney,项目名称:brnkly,代码行数:27,代码来源:LastInWinsReplicationConflictResolver.cs

示例2: HandleConflictedDocument

        private void HandleConflictedDocument(JsonDocument document, TransactionInformation transactionInformation)
        {
            var conflicts = document.DataAsJson.Value<RavenJArray>("Conflicts");
            var currentSource = Database.TransactionalStorage.Id.ToString();
            var historySet = false;

            foreach (var c in conflicts)
            {
                RavenJObject conflict;
                if (Database.Documents.Delete(c.Value<string>(), null, transactionInformation, out conflict) == false)
                    continue;

                if (historySet)
                    continue;

                var conflictSource = conflict.Value<RavenJValue>(Constants.RavenReplicationSource).Value<string>();

                if (conflictSource != currentSource)
                    continue;

                deletedHistory.Value = new RavenJArray
                {
                    new RavenJObject
                    {
                        { Constants.RavenReplicationVersion, conflict[Constants.RavenReplicationVersion] },
                        { Constants.RavenReplicationSource, conflict[Constants.RavenReplicationSource] }
                    }
                };

                historySet = true;
            }
        }
开发者ID:knives-out,项目名称:ravendb,代码行数:32,代码来源:VirtualDeleteAndRemoveConflictsTrigger.cs

示例3: AddToContext

        protected void AddToContext(string key, JsonDocument document)
        {
			if(string.IsNullOrEmpty(key) || key.EndsWith("/"))
				incompleteDocumentKeyContext.Add(document);
			else
				documentKeyContext[key] = document;
        }
开发者ID:randacc,项目名称:ravendb,代码行数:7,代码来源:ScriptedJsonPatcher.cs

示例4: CanBeConsideredAsDuplicate

		private bool CanBeConsideredAsDuplicate(JsonDocument document)
		{
			if (document.Metadata[Constants.RavenReplicationConflict] != null)
				return false;

			return true;
		}
开发者ID:nzaugg,项目名称:ravendb,代码行数:7,代码来源:PrefetchingBehavior.cs

示例5: Add

		public void Add(JsonDocument value)
		{
            Debug.Assert(slim.IsWriteLockHeld);
		    var index = CalculateEtagIndex(value.Etag);
		    innerList.Insert(index, value);
		    loadedSize += value.SerializedSizeOnDisk;
		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:7,代码来源:ConcurrentJsonDocumentSortedList.cs

示例6: TryResolveConflict

			public bool TryResolveConflict(string key, JsonDocument[] conflictedDocs, out JsonDocument resolvedDocument)
			{
				var maxDate = conflictedDocs.Max(x => x.LastModified);
				resolvedDocument = conflictedDocs.FirstOrDefault(x => x.LastModified == maxDate);

				return resolvedDocument != null;
			}
开发者ID:modulexcite,项目名称:docs-8,代码行数:7,代码来源:ClientSideListeners.cs

示例7: TryResolveConflict

			public bool TryResolveConflict(string key, JsonDocument[] conflictedDocs, out JsonDocument resolvedDocument)
			{
				if (conflictedDocs == null || !conflictedDocs.Any())
				{
					resolvedDocument = null;
					return false;
				}

				if (key.StartsWith("Raven/"))
				{
					resolvedDocument = null;
					return false;
				}

				var maxDate = conflictedDocs.Max(x => x.Metadata.Value<DateTimeOffset>(Constants.RavenLastModified));

				resolvedDocument =
					conflictedDocs.FirstOrDefault(x => x.Metadata.Value<DateTimeOffset>(Constants.RavenLastModified) == maxDate);
				if (resolvedDocument != null)
				{
					// Do the logging before we override the metadata
					resolvedDocument.Metadata.Remove("@id");
					resolvedDocument.Metadata.Remove("@etag");
					resolvedDocument.Metadata.Remove(Constants.RavenReplicationConflict);
					resolvedDocument.Metadata.Remove(Constants.RavenReplicationConflictDocument);
				}

				return resolvedDocument != null;
			}
开发者ID:GorelH,项目名称:ravendb,代码行数:29,代码来源:RavenDB_3435.cs

示例8: HandleConflictedDocument

		private void HandleConflictedDocument(JsonDocument document, TransactionInformation transactionInformation)
		{
			var conflicts = document.DataAsJson.Value<RavenJArray>("Conflicts");
			var currentSource = Database.TransactionalStorage.Id.ToString();

			foreach (var c in conflicts)
			{
				var conflict = Database.Get(c.Value<string>(), transactionInformation);
				var conflictSource = conflict.Metadata.Value<RavenJValue>(Constants.RavenReplicationSource).Value<string>();

				if (conflictSource != currentSource)
					continue;

				this.deletedHistory.Value = new RavenJArray
				{
					new RavenJObject
					{
						{ Constants.RavenReplicationVersion, conflict.Metadata[Constants.RavenReplicationVersion] },
						{ Constants.RavenReplicationSource, conflict.Metadata[Constants.RavenReplicationSource] }
					}
				};

				return;
			}
		}
开发者ID:jjchiw,项目名称:ravendb,代码行数:25,代码来源:VirtualDeleteTrigger.cs

示例9: AfterStorageCommitBeforeWorkNotifications

		public void AfterStorageCommitBeforeWorkNotifications(PrefetchingUser user, JsonDocument[] documents)
		{
			PrefetchingBehavior value;
			if (prefetchingBehaviors.TryGetValue(user, out value) == false)
				return;
			value.AfterStorageCommitBeforeWorkNotifications(documents);
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:7,代码来源:Prefetcher.cs

示例10: PickLikelyColumns

        private IList<ColumnDefinition> PickLikelyColumns(JsonDocument[] sampleDocuments, string context, IList<PriorityColumn> priorityColumns)
        {
            if (priorityColumns == null || priorityColumns.Count == 0)
            {
                priorityColumns = DefaultPriorityColumns;
            }

            // only consider nested properties if any of the priority columns refers to a nested property
            var includeNestedProperties = priorityColumns.Any(c => c.PropertyNamePattern.Contains("\\."));

			var columns = DocumentHelpers.GetPropertiesFromDocuments(sampleDocuments, includeNestedProperties)
				.GroupBy(p => p)
				.Select(g => new { Property = g.Key, Occurence = g.Count() / (double)sampleDocuments.Length })
				.Select(p => new { p.Property, Importance = p.Occurence + ImportanceBoost(p.Property, context, priorityColumns) })
				.OrderByDescending(p => p.Importance)
				.ThenBy(p => p.Property)
				.Select(p => new ColumnDefinition
								 {
									 Binding = p.Property,
									 Header = p.Property,
									 DefaultWidth = GetDefaultColumnWidth(p.Property, priorityColumns)
								 })
				.Take(6)
				.ToList();

            return columns;
        }
开发者ID:925coder,项目名称:ravendb,代码行数:27,代码来源:ColumnSuggester.cs

示例11: AfterStorageCommitBeforeWorkNotifications

		public void AfterStorageCommitBeforeWorkNotifications(PrefetchingUser user, JsonDocument[] documents)
		{
			foreach (var prefetcher in prefetchingBehaviors.Where(x => x.PrefetchingUser == user))
			{
				prefetcher.AfterStorageCommitBeforeWorkNotifications(documents);
			}
		}
开发者ID:Nakro,项目名称:ravendb,代码行数:7,代码来源:Prefetcher.cs

示例12: TryResolve

		public override bool TryResolve(string id, RavenJObject metadata, RavenJObject document, JsonDocument existingDoc,
		                                Func<string, JsonDocument> getDocument, out RavenJObject metadataToSave,
		                                out RavenJObject documentToSave)
		{
			var existingDocumentIsInConflict = existingDoc.Metadata[Constants.RavenReplicationConflict] != null;
			var existingDocumentIsDeleted = existingDoc.Metadata[Constants.RavenDeleteMarker] != null
			                                && existingDoc.Metadata[Constants.RavenDeleteMarker].Value<bool>();

			metadataToSave = null;
			documentToSave = null;

			if (existingDocumentIsInConflict && existingDocumentIsDeleted == false)
			{
				var conflictIds =
					existingDoc.DataAsJson.Value<RavenJArray>("Conflicts")
					           .Select(x => x.Value<string>())
					           .ToArray();

				if (conflictIds.Length == 0) return false;

				if (conflictIds
					    .Select(getDocument)
					    .Where(x => x != null)
					    .All(doc => Historian.IsDirectChildOfCurrent(metadata, doc.Metadata)) == false)
					return false;

				metadataToSave = metadata;
				documentToSave = document;

				return true;
			}

			return false;
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:34,代码来源:DefaultDocumentReplicationConflictResolver.cs

示例13: Add

        public void Add(JsonDocument value)
        {
            Debug.Assert(slim.IsWriteLockHeld);

            innerList[value.Etag] = value;

            loadedSize += value.SerializedSizeOnDisk;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:8,代码来源:ConcurrentJsonDocumentSortedList.cs

示例14: TryResolve

		protected override bool TryResolve(string id, RavenJObject metadata, RavenJObject document, JsonDocument existingDoc,
		                                Func<string, JsonDocument> getDocument, out RavenJObject metadataToSave,
		                                out RavenJObject documentToSave)
		{
			metadataToSave = metadata;
			documentToSave = document;

			return true;
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:9,代码来源:RemoteDocumentReplicationConflictResolver.cs

示例15: CreateSuggestedBindingsFromDocuments

 private IList<string> CreateSuggestedBindingsFromDocuments(JsonDocument[] jsonDocuments)
 {
     var bindings = DocumentHelpers.GetPropertiesFromDocuments(jsonDocuments, true).Distinct()
         .Concat(DocumentHelpers.GetMetadataFromDocuments(jsonDocuments, true).Distinct().Select(b => "$Meta:" + b))
         .Concat(new[] {"$JsonDocument:Etag", "$JsonDocument:LastModified", "$Temp:Score"})
         .ToArray();
     
     return bindings;
 }
开发者ID:925coder,项目名称:ravendb,代码行数:9,代码来源:ColumnSuggester.cs


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