本文整理汇总了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;
}
示例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;
}
}
示例3: AddToContext
protected void AddToContext(string key, JsonDocument document)
{
if(string.IsNullOrEmpty(key) || key.EndsWith("/"))
incompleteDocumentKeyContext.Add(document);
else
documentKeyContext[key] = document;
}
示例4: CanBeConsideredAsDuplicate
private bool CanBeConsideredAsDuplicate(JsonDocument document)
{
if (document.Metadata[Constants.RavenReplicationConflict] != null)
return false;
return true;
}
示例5: Add
public void Add(JsonDocument value)
{
Debug.Assert(slim.IsWriteLockHeld);
var index = CalculateEtagIndex(value.Etag);
innerList.Insert(index, value);
loadedSize += value.SerializedSizeOnDisk;
}
示例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;
}
示例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;
}
示例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;
}
}
示例9: AfterStorageCommitBeforeWorkNotifications
public void AfterStorageCommitBeforeWorkNotifications(PrefetchingUser user, JsonDocument[] documents)
{
PrefetchingBehavior value;
if (prefetchingBehaviors.TryGetValue(user, out value) == false)
return;
value.AfterStorageCommitBeforeWorkNotifications(documents);
}
示例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;
}
示例11: AfterStorageCommitBeforeWorkNotifications
public void AfterStorageCommitBeforeWorkNotifications(PrefetchingUser user, JsonDocument[] documents)
{
foreach (var prefetcher in prefetchingBehaviors.Where(x => x.PrefetchingUser == user))
{
prefetcher.AfterStorageCommitBeforeWorkNotifications(documents);
}
}
示例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;
}
示例13: Add
public void Add(JsonDocument value)
{
Debug.Assert(slim.IsWriteLockHeld);
innerList[value.Etag] = value;
loadedSize += value.SerializedSizeOnDisk;
}
示例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;
}
示例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;
}