예제 #1
0
        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");
        }
예제 #2
0
        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;
        }
예제 #3
0
		public bool CanExecute(DocumentViewModel document)
		{
			return document != null;
		}
예제 #4
0
		public void Execute(DocumentViewModel document)
		{
			Clipboard.SetText(document.Contents.ToString(Formatting.Indented));
		}