public void Initialize(JsonDocument doc) { document = doc; Id = document.Key; JsonData = PrepareRawJsonString(document.DataAsJson); IsProjection = string.IsNullOrEmpty(Id) && (document.Metadata == null); if (IsProjection) { return; } JsonMetadata = PrepareRawJsonString(document.Metadata); metadata = ParseJsonToDictionary(document.Metadata); LastModified = metadata.IfPresent <DateTime>("Last-Modified"); CollectionType = DocumentViewModel.DetermineCollectionType(document.Metadata); ClrType = metadata.IfPresent <string>("Raven-Clr-Type"); }
public void UpdateDocumentFromJsonDocument() { Id = document.Key; JsonData = PrepareRawJsonString(document.DataAsJson); IsProjection = string.IsNullOrEmpty(Id) && (document.Metadata == null || document.Metadata.Any() == false); if (IsProjection) { return; } if (document.Metadata != null) { foreach (var property in document.Metadata.ToList()) { if (property.Key.StartsWith("@")) { document.Metadata.Remove(property.Key); } } } JsonMetadata = PrepareRawJsonString(document.Metadata); metadata = ParseJsonToDictionary(document.Metadata); LastModified = document.LastModified ?? DateTime.MinValue; if (LastModified.Kind == DateTimeKind.Utc) { LastModified = LastModified.ToLocalTime(); } CollectionType = DocumentViewModel.DetermineCollectionType(document.Metadata); ClrType = metadata.IfPresent <string>(Constants.RavenClrType); Etag = document.Etag.ToString(); NonAuthoritiveInformation = document.NonAuthoritiveInformation ?? false; }
public bool CanExecute(DocumentViewModel document) { return document != null; }
public void Execute(DocumentViewModel document) { Clipboard.SetText(document.Contents.ToString(Formatting.Indented)); }