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


C# RavenJObject.ContainsKey方法代码示例

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


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

示例1: OnPut

        public override void OnPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
        {
            VersioningConfiguration versioningConfiguration;

            if (metadata.ContainsKey(Constants.RavenCreateVersion))
            {
                metadata.__ExternalState[Constants.RavenCreateVersion] = metadata[Constants.RavenCreateVersion];
                metadata.Remove(Constants.RavenCreateVersion);
            }

            if (metadata.ContainsKey(Constants.RavenIgnoreVersioning))
            {
                metadata.__ExternalState[Constants.RavenIgnoreVersioning] = metadata[Constants.RavenIgnoreVersioning];
                metadata.Remove(Constants.RavenIgnoreVersioning);
                return;
            }

            if (TryGetVersioningConfiguration(key, metadata, out versioningConfiguration) == false)
                return;

            var revision = GetNextRevisionNumber(key);

            using (Database.DisableAllTriggersForCurrentThread())
            {
                RemoveOldRevisions(key, revision, versioningConfiguration, transactionInformation);
            }
            metadata.__ExternalState["Next-Revision"] = revision;

            metadata.__ExternalState["Parent-Revision"] = metadata.Value<string>(VersioningUtil.RavenDocumentRevision);

            metadata[VersioningUtil.RavenDocumentRevisionStatus] = RavenJToken.FromObject("Current");
            metadata[VersioningUtil.RavenDocumentRevision] = RavenJToken.FromObject(revision);
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:33,代码来源:VersioningPutTrigger.cs

示例2: GetLastModified

		private static DateTimeOffset GetLastModified(RavenJObject metadata)
		{
			if (metadata.ContainsKey(Constants.LastModified))
				return metadata.Value<DateTimeOffset>(Constants.LastModified);

			if (metadata.ContainsKey(Constants.RavenLastModified))
				return metadata.Value<DateTimeOffset>(Constants.RavenLastModified);

			throw new InvalidOperationException("Could not find last modification date in metadata");
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:10,代码来源:LatestFileSynchronizationConflictResolver.cs

示例3: HandleConflictDocuments

        public static RavenJToken HandleConflictDocuments(RavenJObject metadata)
        {
            if (metadata == null)
                return null;

            if (metadata.ContainsKey(Constants.RavenReplicationConflictDocument))
                metadata.Add(Constants.RavenReplicationConflictDocumentForcePut, true);

            if (metadata.ContainsKey(Constants.RavenReplicationConflict))
                metadata.Add(Constants.RavenReplicationConflictSkipResolution, true);

            return metadata;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:13,代码来源:SmugglerHelper.cs

示例4: OnPut

		public override void OnPut(string name, RavenJObject headers)
		{
			if (headers.ContainsKey(Constants.RavenCreateVersion))
			{
				headers.__ExternalState[Constants.RavenCreateVersion] = headers[Constants.RavenCreateVersion];
				headers.Remove(Constants.RavenCreateVersion);
			}

			FileSystem.Storage.Batch(accessor =>
			{
				VersioningConfiguration versioningConfiguration;
				if (TryGetVersioningConfiguration(name, headers, accessor, out versioningConfiguration) == false) 
					return;

				var revision = GetNextRevisionNumber(name, accessor);

				using (FileSystem.DisableAllTriggersForCurrentThread())
				{
					RemoveOldRevisions(name, revision, versioningConfiguration);
				}

				headers.__ExternalState["Next-Revision"] = revision;
				headers.__ExternalState["Parent-Revision"] = headers.Value<string>(VersioningUtil.RavenFileRevision);

				headers[VersioningUtil.RavenFileRevisionStatus] = RavenJToken.FromObject("Current");
				headers[VersioningUtil.RavenFileRevision] = RavenJToken.FromObject(revision);
			});
		}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:28,代码来源:VersioningPutTrigger.cs

示例5: FilterDocuments

		public bool FilterDocuments(string destinationId, string key, RavenJObject metadata)
		{
			if (key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase)) // don't replicate system docs
			{
				if (key.StartsWith("Raven/Hilo/", StringComparison.InvariantCultureIgnoreCase) == false) // except for hilo documents
					return false;
			}
			if (metadata.ContainsKey(Constants.NotForReplication) && metadata.Value<bool>(Constants.NotForReplication)) // not explicitly marked to skip
				return false;
			if (metadata[Constants.RavenReplicationConflict] != null) // don't replicate conflicted documents, that just propagate the conflict
				return false;

			if (metadata.Value<string>(Constants.RavenReplicationSource) == destinationId) // prevent replicating back to source
				return false;

			switch (ReplicationOptionsBehavior)
			{
				case TransitiveReplicationOptions.None:
					var value = metadata.Value<string>(Constants.RavenReplicationSource);
					var replicateDoc = value == null || (value == CurrentDatabaseId);
					return replicateDoc;
			}
			return true;

		}
开发者ID:arelee,项目名称:ravendb,代码行数:25,代码来源:ReplicationStrategy.cs

示例6: DetermineWork

        public SynchronizationWorkItem DetermineWork(string file, RavenJObject localMetadata, RavenJObject destinationMetadata, string localServerUrl, out NoSyncReason reason)
        {
            reason = NoSyncReason.Unknown;

            if (localMetadata == null)
            {
                reason = NoSyncReason.SourceFileNotExist;
                return null;
            }

            if (destinationMetadata != null && destinationMetadata[SynchronizationConstants.RavenSynchronizationConflict] != null && destinationMetadata[SynchronizationConstants.RavenSynchronizationConflictResolution] == null)
            {
                reason = NoSyncReason.DestinationFileConflicted;
                return null;
            }

            if (localMetadata[SynchronizationConstants.RavenSynchronizationConflict] != null)
            {
                reason = NoSyncReason.SourceFileConflicted;
                return null;
            }

            if (localMetadata[SynchronizationConstants.RavenDeleteMarker] != null)
            {
                if (localMetadata.ContainsKey(SynchronizationConstants.RavenRenameFile))
                {
                    var rename = localMetadata.Value<string>(SynchronizationConstants.RavenRenameFile);

                    if (destinationMetadata != null)
                        return new RenameWorkItem(file, rename, localServerUrl, storage);

                    return new ContentUpdateWorkItem(rename, localServerUrl, storage, sigGenerator);
                    // we have a rename tombstone but file does not exists on destination
                }
                return new DeleteWorkItem(file, localServerUrl, storage);
            }

            if (destinationMetadata != null && Historian.IsDirectChildOfCurrent(localMetadata, destinationMetadata))
            {
                reason = NoSyncReason.ContainedInDestinationHistory;
                return null;
            }

            // file exists on dest and has the same content
            if (destinationMetadata != null && localMetadata.Value<string>("Content-MD5") == destinationMetadata.Value<string>("Content-MD5"))
            {
                // check metadata to detect if any synchronization is needed
                if (localMetadata.Keys.Except(new[] { Constants.MetadataEtagField, Constants.RavenLastModified, Constants.LastModified })
                                 .Any(key => !destinationMetadata.ContainsKey(key) || localMetadata[key] != destinationMetadata[key]))
                {
                    return new MetadataUpdateWorkItem(file, localServerUrl, destinationMetadata, storage);
                }

                reason = NoSyncReason.SameContentAndMetadata;

                return null; // the same content and metadata - no need to synchronize
            }

            return new ContentUpdateWorkItem(file, localServerUrl, storage, sigGenerator);
        }
开发者ID:heinnge,项目名称:ravendb,代码行数:60,代码来源:SynchronizationStrategy.cs

示例7: OnPut

        public override void OnPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
        {
            if (!metadata.ContainsKey("IsRoutable") || !metadata.Value<bool>("IsRoutable")) {
                return;
            }

            RavenJToken parentIdToken;
            RavenJToken slugToken;
            if (document.TryGetValue("ParentId", out parentIdToken) && document.TryGetValue("Slug", out slugToken)) {
                var parentId = parentIdToken.Value<string>();
                var slug = slugToken.Value<string>();

                string parentPath = null;
                if (!String.IsNullOrEmpty(parentId)) {
                    var parent = Database.Get(parentId, transactionInformation);
                    parentPath = parent.DataAsJson["Path"].Value<string>();
                }

                if (String.IsNullOrEmpty(parentPath)) {
                    document["Path"] = slug;
                } else {
                    document["Path"] = parentPath + "/" + slug;
                }
            }

            base.OnPut(key, document, metadata, transactionInformation);
        }
开发者ID:thoemmi,项目名称:ViewComposition,代码行数:27,代码来源:PathUpdateTrigger.cs

示例8: AssertLocalFileExistsAndIsNotConflicted

        protected void AssertLocalFileExistsAndIsNotConflicted(RavenJObject sourceMetadata)
		{
			if (sourceMetadata == null)
				throw new SynchronizationException(string.Format("File {0} does not exist", FileName));

            if (sourceMetadata.ContainsKey(SynchronizationConstants.RavenSynchronizationConflict))
                throw new SynchronizationException(string.Format("File {0} is conflicted", FileName));
		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:8,代码来源:SynchronizationWorkItem.cs

示例9: AllowRead

		public override ReadVetoResult AllowRead(string key, RavenJObject metadata, ReadOperation operation, TransactionInformation transactionInformation)
		{
			if (operation != ReadOperation.Index)
				return ReadVetoResult.Allowed;
			if (metadata.ContainsKey("Deleted") == false)
				return ReadVetoResult.Allowed;
			return ReadVetoResult.Ignore;
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:8,代码来源:HideVirtuallyDeletedDocument.cs

示例10: CreateCommand

    public static ICommandData CreateCommand(RavenJObject jsonCommand, TransactionInformation transactionInformation)
		{
			var key = jsonCommand["Key"].Value<string>();
			switch (jsonCommand.Value<string>("Method"))
			{
				case "PUT":
					var putCommand = new PutCommandData
					{
						Key = key,
						Etag = GetEtagFromCommand(jsonCommand),
						Document = jsonCommand["Document"] as RavenJObject,
						Metadata = jsonCommand["Metadata"] as RavenJObject,
						TransactionInformation = transactionInformation
					};
			        ValidateMetadataKeys(putCommand.Metadata);
			        return putCommand;
				case "DELETE":
					return new DeleteCommandData
					{
						Key = key,
						Etag = GetEtagFromCommand(jsonCommand),
						TransactionInformation = transactionInformation
					};
				case "PATCH":
					return new PatchCommandData
					{
						Key = key,
						Etag = GetEtagFromCommand(jsonCommand),
						TransactionInformation = transactionInformation,
						Metadata = jsonCommand["Metadata"] as RavenJObject,
						Patches = jsonCommand
							.Value<RavenJArray>("Patches")
							.Cast<RavenJObject>()
							.Select(PatchRequest.FromJson)
							.ToArray(),
						PatchesIfMissing = jsonCommand["PatchesIfMissing"] == null ? null : jsonCommand
							.Value<RavenJArray>("PatchesIfMissing")
							.Cast<RavenJObject>()
							.Select(PatchRequest.FromJson)
							.ToArray(),
						SkipPatchIfEtagMismatch = jsonCommand.ContainsKey("SkipPatchIfEtagMismatch") && jsonCommand.Value<bool>("SkipPatchIfEtagMismatch")
					};
				case "EVAL":
					var debug = jsonCommand["DebugMode"].Value<bool>();
					return new ScriptedPatchCommandData
					{
						Key = key,
						Metadata = jsonCommand["Metadata"] as RavenJObject,
						Etag = GetEtagFromCommand(jsonCommand),
						TransactionInformation = transactionInformation,
						Patch = ScriptedPatchRequest.FromJson(jsonCommand.Value<RavenJObject>("Patch")),
						PatchIfMissing = jsonCommand["PatchIfMissing"] == null ? null : ScriptedPatchRequest.FromJson(jsonCommand.Value<RavenJObject>("PatchIfMissing")),
						DebugMode = debug
					};
				default:
					throw new ArgumentException("Batching only supports PUT, PATCH, EVAL and DELETE.");
			}
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:58,代码来源:CommandDataFactory.cs

示例11: DeserializeHistory

        public static List<HistoryItem> DeserializeHistory(RavenJObject metadata)
        {
            var history = new List<HistoryItem>();
            if (metadata.ContainsKey(SynchronizationConstants.RavenSynchronizationHistory))
            {
                var array = (RavenJArray) metadata[SynchronizationConstants.RavenSynchronizationHistory];
                var items = array.Values<RavenJObject>().Select(x => JsonExtensions.JsonDeserialization<HistoryItem>(x));
                return new List<HistoryItem>(items);
            }

            return history;
        }
开发者ID:cocytus,项目名称:ravendb,代码行数:12,代码来源:Historian.cs

示例12: InitializeMetadata

        public void InitializeMetadata(string name, RavenJObject metadata)
        {
            if (metadata.ContainsKey(Constants.RavenCreateVersion))
            {
                metadata.__ExternalState[Constants.RavenCreateVersion] = metadata[Constants.RavenCreateVersion];
                metadata.Remove(Constants.RavenCreateVersion);
            }

            if (metadata.ContainsKey(Constants.RavenIgnoreVersioning))
            {
                metadata.__ExternalState[Constants.RavenIgnoreVersioning] = metadata[Constants.RavenIgnoreVersioning];
                metadata.Remove(Constants.RavenIgnoreVersioning);
                return;
            }

            fileSystem.Storage.Batch(accessor =>
            {
                FileVersioningConfiguration versioningConfiguration;
                if (TryGetVersioningConfiguration(name, metadata, accessor, out versioningConfiguration) == false)
                    return;

                long revision;

                if (metadata.__ExternalState.ContainsKey("Synchronization-Next-Revision"))
                    revision = (long) metadata.__ExternalState["Synchronization-Next-Revision"];
                else
                    revision = GetNextRevisionNumber(name, accessor);

                RemoveOldRevisions(name, revision, versioningConfiguration);

                metadata.__ExternalState["Next-Revision"] = revision;
                metadata.__ExternalState["Parent-Revision"] = metadata.Value<string>(VersioningUtil.RavenFileRevision);

                metadata[VersioningUtil.RavenFileRevisionStatus] = RavenJToken.FromObject("Current");
                metadata[VersioningUtil.RavenFileRevision] = RavenJToken.FromObject(revision);
            });
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:37,代码来源:VersioningTriggerActions.cs

示例13: FilterDocuments

        public bool FilterDocuments(string destinationId, string key, RavenJObject metadata, out string reason)
        {
            if (IsSystemDocumentId(key))
            {
                reason = string.Format("Will not replicate document '{0}' to '{1}' because it is a system document", key, destinationId);
                Log.Debug(reason);
                return false;
            }
            if (metadata.ContainsKey(Constants.NotForReplication) && metadata.Value<bool>(Constants.NotForReplication))
                // not explicitly marked to skip
            {
                reason = string.Format("Will not replicate document '{0}' to '{1}' because it was marked as not for replication", key, destinationId);
                Log.Debug(reason); 
                return false;
            }

            if (metadata[Constants.RavenReplicationConflict] != null)
                // don't replicate conflicted documents, that just propagate the conflict
            {
                reason = string.Format("Will not replicate document '{0}' to '{1}' because it a conflict document", key, destinationId);
                Log.Debug(reason); 
                return false;
            }

            if (OriginsFromDestination(destinationId, metadata)) // prevent replicating back to source
            {
                reason = string.Format("Will not replicate document '{0}' to '{1}' because the destination server is the same server it originated from", key, destinationId);
                Log.Debug(reason); 
                return false;
            }

            switch (ReplicationOptionsBehavior)
            {
                case TransitiveReplicationOptions.None:
                    var value = metadata.Value<string>(Constants.RavenReplicationSource);
                    if (value != null &&  (value != CurrentDatabaseId))
                    {
                        reason = string.Format("Will not replicate document '{0}' to '{1}' because it was not created on the current server, and TransitiveReplicationOptions = none", key, destinationId);
                        Log.Debug(reason);
                        return false;
                    }
                    break;
            }
            reason = string.Format("Will replicate '{0}' to '{1}'", key, destinationId);
            Log.Debug(reason);
            return true;

        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:48,代码来源:ReplicationStrategy.cs

示例14: AfterPut

        public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Etag etag, TransactionInformation transactionInformation)
        {
            if (!metadata.__ExternalState.ContainsKey(RavenDocumentRevision))
                return;

            using (Database.DisableAllTriggersForCurrentThread())
            {
                var revisionMetadata = new RavenJObject(metadata);
                revisionMetadata[RavenDocumentRevisionStatus] = RavenJToken.FromObject("Historical");
                revisionMetadata.Remove(RavenDocumentRevision);

                if (revisionMetadata.ContainsKey(RavenDocumentEnsureUniqueConstraints))
                    revisionMetadata.Remove(RavenDocumentEnsureUniqueConstraints);

                var revisionCopy = new RavenJObject(document);
                var revisionkey = key + RevisionSegment + metadata.__ExternalState[RavenDocumentRevision];
                Database.Documents.Put(revisionkey, null, revisionCopy, revisionMetadata, transactionInformation);
            }
        }
开发者ID:nickchampion,项目名称:RavenDB.Bundles.Revisions,代码行数:19,代码来源:RevisionDocumentPutTrigger.cs

示例15: AfterPut

        public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Guid etag, TransactionInformation transactionInformation)
        {
            // leave raven system docs alone
            if (key.StartsWith("Raven/"))
                return;

            // when there's already a Created date written, this is not the original insert
            if (metadata.ContainsKey("Created"))
                return;

            // get the timestamp set for the last-modified date
            var timestamp = metadata.Value<DateTime>(Constants.LastModified);

            // copy the metadata and add the timestamp
            var newMetadata = (RavenJObject)metadata.CreateSnapshot();
            newMetadata.Add("Created", timestamp);

            // update the metadata in the document
            using (Database.DisableAllTriggersForCurrentThread())
                Database.PutDocumentMetadata(key, newMetadata);
        }
开发者ID:tzarger,项目名称:contrib,代码行数:21,代码来源:CreatedDateTrigger.cs


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