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


C# RavenJObject.Value方法代码示例

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


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

示例1: 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

示例2: ModifyResult

		private static void ModifyResult(RavenJObject result)
		{
			var tags = result.Value<string>("Tags");
			if (tags != null)
			{
				result["Tags"] =
					new RavenJArray(tags.Split(new[] {' ', ',', ';'}, StringSplitOptions.RemoveEmptyEntries));
			}
			else
			{
				result["Tags"] = new RavenJArray();
			}
			var deps = result.Value<string>("Dependencies");
			if (deps != null)
			{
				result["Dependencies"] =
					new RavenJArray(deps.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)
						                .Select(s =>
							                {
								                var strings = s.Split(':');
								                return RavenJObject.FromObject(new {Package = strings[0], Version = strings[1]});
							                }));
			}
			result["PackageId"] = result["Id"];
			result.Remove("Id");
			result.Remove("__metadata");
			result.Remove("DownloadCount");
		}
开发者ID:ayende,项目名称:nuget.perf,代码行数:28,代码来源:Program.cs

示例3: AfterPut

		public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, System.Guid etag, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/"))
			{
				return;
			}

			var entityName = metadata.Value<string>(Constants.RavenEntityName) + "/";

			var properties = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

			if (properties == null || properties.Length <= 0) 
				return;

			var constraintMetaObject = new RavenJObject { { Constants.IsConstraintDocument, true } };
			constraintMetaObject.EnsureSnapshot();
			foreach (var property in properties)
			{
				var propName = ((RavenJValue)property).Value.ToString();
				var uniqueValue = document.Value<string>(propName);
				if(uniqueValue == null)
					continue;
				string documentName = "UniqueConstraints/" + entityName + propName + "/" +Util.EscapeUniqueValue(uniqueValue);
				Database.Put(
					documentName,
					null,
					RavenJObject.FromObject(new { RelatedId = key }),
					(RavenJObject)constraintMetaObject.CreateSnapshot(),
					transactionInformation);
			}
		}
开发者ID:remcoros,项目名称:ravendb,代码行数:31,代码来源:UniqueConstraintsPutTrigger.cs

示例4: OnPut

		public override void OnPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase))
				return;

			if (metadata.Value<string>(VersioningUtil.RavenDocumentRevisionStatus) == "Historical")
				return;

			var versioningConfiguration = Database.GetDocumentVersioningConfiguration(metadata);
			if (versioningConfiguration == null || versioningConfiguration.Exclude)
				return;

			using (Database.DisableAllTriggersForCurrentThread())
			{
				var copyMetadata = new RavenJObject(metadata);
				copyMetadata[VersioningUtil.RavenDocumentRevisionStatus] = RavenJToken.FromObject("Historical");
				copyMetadata[Constants.RavenReadOnly] = true;
				copyMetadata.Remove(VersioningUtil.RavenDocumentRevision);
				var parentRevision = metadata.Value<string>(VersioningUtil.RavenDocumentRevision);
				if (parentRevision != null)
				{
					copyMetadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
					metadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
				}

				PutResult newDoc = Database.Put(key + "/revisions/", null, document, copyMetadata,
				                                transactionInformation);
				int revision = int.Parse(newDoc.Key.Split('/').Last());

				RemoveOldRevisions(key, revision, versioningConfiguration, transactionInformation);

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

示例5: AfterPut

		public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, System.Guid etag, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/"))
			{
				return;
			}

			var entityName = metadata.Value<string>(Constants.RavenEntityName) + "/";

			var properties = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

			if (properties == null || properties.Count() <= 0) 
				return;

			var constraintMetaObject = new RavenJObject { { Constants.IsConstraintDocument, true } };
			foreach (var property in properties)
			{
				var propName = ((RavenJValue)property).Value.ToString();
				Database.Put(
					"UniqueConstraints/" + entityName + propName + "/" + document.Value<string>(propName),
					null,
					RavenJObject.FromObject(new { RelatedId = key }),
					constraintMetaObject,
					transactionInformation);
			}
		}
开发者ID:seankearon,项目名称:ravendb,代码行数:26,代码来源:UniqueConstraintsPutTrigger.cs

示例6: TransformToFullConflictHistory

        private static List<HistoryItem> TransformToFullConflictHistory(RavenJObject metadata)
        {
            var version = metadata.Value<long>(SynchronizationConstants.RavenSynchronizationVersion);
            var serverId = metadata.Value<string>(SynchronizationConstants.RavenSynchronizationSource);
            var fullHistory = Historian.DeserializeHistory(metadata);
            fullHistory.Add(new HistoryItem { ServerId = serverId, Version = version });

            return fullHistory;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:9,代码来源:ConflictDetector.cs

示例7: AllowPut

		public override VetoResult AllowPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/"))
			{
				return VetoResult.Allowed;
			}

			var entityName = metadata.Value<string>(Constants.RavenEntityName);

			if (string.IsNullOrEmpty(entityName))
			{
				return VetoResult.Allowed;
			}
			entityName += "/";

			var properties = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

			if (properties == null || properties.Length <= 0)
				return VetoResult.Allowed;

			var invalidFields = new StringBuilder();

			foreach (var property in properties)
			{
				var propName = property.Value<string>();

				var prefix = "UniqueConstraints/" + entityName + property + "/";
				var prop = document[propName];

				if (prop == null || prop.Type == JTokenType.Null)
					continue;

				var array = prop as RavenJArray;
				var checkKeys = array != null ? array.Select(p => p.Value<string>()) : new[] { prop.Value<string>() };

				foreach (var checkKey in checkKeys)
				{
					var checkDoc = Database.Get(prefix + Util.EscapeUniqueValue(checkKey), transactionInformation);

					if (checkDoc == null)
						continue;

					var checkId = checkDoc.DataAsJson.Value<string>("RelatedId");

					if (checkId != key)
						invalidFields.Append(property + ", ");
				}
			}

			if (invalidFields.Length > 0)
			{
				invalidFields.Length = invalidFields.Length - 2;
				return VetoResult.Deny("Ensure unique constraint violated for fields: " + invalidFields);
			}

			return VetoResult.Allowed;
		}
开发者ID:thoemmi,项目名称:ravendb,代码行数:57,代码来源:UniqueConstraintsPutTrigger.cs

示例8: AllowPut

	    public override VetoResult AllowPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/"))
			{
				return VetoResult.Allowed;
			}

			var entityName = metadata.Value<string>(Constants.RavenEntityName);

			if (string.IsNullOrEmpty(entityName))
			{
				return VetoResult.Allowed;
			}
			entityName += "/";

			var properties = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

			if (properties == null || properties.Length <= 0)
				return VetoResult.Allowed;

			var invalidFields = new StringBuilder();

			foreach (var property in properties)
			{
			    var constraint = Util.GetConstraint(property);

                var prefix = "UniqueConstraints/" + entityName + constraint.PropName+ "/";
                var prop = document[constraint.PropName];
                
			    string[] uniqueValues;
			    if (!Util.TryGetUniqueValues(prop, out uniqueValues))
                    continue;

				foreach (var uniqueValue in uniqueValues)
				{
                    var escapedUniqueValue = Util.EscapeUniqueValue(uniqueValue, constraint.CaseInsensitive);
				    var checkDocKey = prefix + escapedUniqueValue;
                    var checkDoc = Database.Documents.Get(checkDocKey, transactionInformation);

					if (checkDoc == null)
						continue;

				    var checkId = GetRelatedIdFromUniqueConstraintsDocument(checkDoc, escapedUniqueValue);

					if (!string.IsNullOrEmpty(checkId) && checkId != key)
						invalidFields.Append(constraint.PropName + ", ");
				}
			}

			if (invalidFields.Length > 0)
			{
				invalidFields.Length = invalidFields.Length - 2;
				return VetoResult.Deny("Ensure unique constraint violated for fields: " + invalidFields);
			}

			return VetoResult.Allowed;
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:57,代码来源:UniqueConstraintsPutTrigger.cs

示例9: 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

示例10: OnRead

        public override void OnRead(string key, RavenJObject document, RavenJObject metadata, ReadOperation operation, TransactionInformation transactionInformation)
        {
            var linkName = metadata.Value<string>("Raven-Link-Name");
            var link = metadata.Value<string>("Raven-Link");
            if (link == null)
                return;

            var linkedDocument = Database.Get(link, transactionInformation);
            document.Add(linkName, linkedDocument.ToJson());
        }
开发者ID:jamesfarrer,项目名称:docs,代码行数:10,代码来源:Read.cs

示例11: CreateCommand

		public static ICommandData CreateCommand(RavenJObject jsonCommand, TransactionInformation transactionInformation)
		{
			var key = jsonCommand["Key"].Value<string>();
			switch (jsonCommand.Value<string>("Method"))
			{
				case "PUT":
					return new PutCommandData
					{
						Key = key,
						Etag = GetEtagFromCommand(jsonCommand),
						Document = jsonCommand["Document"] as RavenJObject,
						Metadata = jsonCommand["Metadata"] as RavenJObject,
						TransactionInformation = transactionInformation
					};
				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(),
					};
				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:cocytus,项目名称:ravendb,代码行数:55,代码来源:CommandDataFactory.cs

示例12: ExtractDataAndDo

 private void ExtractDataAndDo(RavenJObject result, Action<Employee, string> action)
 {
     var attachmentId = result.Value<string>("AttachmentId");
     var employeeId = result.Value<string>("RelatedEntityId");
     using (var session = DocumentStore.OpenSession())
     {
         var employee = session.Load<Employee>(employeeId);
         action(employee, attachmentId);
         session.SaveChanges();
     }
 }
开发者ID:CarlosGM,项目名称:CommonJobs,代码行数:11,代码来源:MoveAttachmentToSlotBaseMigration.cs

示例13: AfterPut

        public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Etag etag, TransactionInformation transactionInformation)
        {
            if (key.StartsWith("Raven/"))
            {
                return;
            }

            var entityName = metadata.Value<string>(Constants.RavenEntityName) + "/";

            var properties = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

            if (properties == null || properties.Length <= 0)
                return;

            foreach (var property in properties)
            {
                var constraint = Util.GetConstraint(property);
                var prop = document[constraint.PropName];

                string[] uniqueValues;
                if (!Util.TryGetUniqueValues(prop, out uniqueValues))
                    continue;

                var prefix = "UniqueConstraints/" + entityName + constraint.PropName + "/";

                foreach (var uniqueValue in uniqueValues)
                {
                    var escapedUniqueValue = Util.EscapeUniqueValue(uniqueValue, constraint.CaseInsensitive);
                    var uniqueConstraintsDocumentKey = prefix + escapedUniqueValue;
                    var uniqueConstraintsDocument = Database.Documents.Get(uniqueConstraintsDocumentKey, transactionInformation);                    

                    if (uniqueConstraintsDocument != null)
                    {
                        uniqueConstraintsDocument = DeepCloneDocument(uniqueConstraintsDocument);
                        ConvertUniqueConstraintsDocumentIfNecessary(uniqueConstraintsDocument, escapedUniqueValue); // backward compatibility
}
                    else
                        uniqueConstraintsDocument = new JsonDocument();

                    AddConstraintToUniqueConstraintsDocument(uniqueConstraintsDocument, escapedUniqueValue, key);
                    uniqueConstraintsDocument.Metadata[Constants.IsConstraintDocument] = true;

                    Database.Documents.Put(
                        uniqueConstraintsDocumentKey,
                        null,
                        uniqueConstraintsDocument.DataAsJson,
                        uniqueConstraintsDocument.Metadata,
                        transactionInformation);
                }
            }
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:51,代码来源:UniqueConstraintsPutTrigger.cs

示例14: AllowPut

		public override VetoResult AllowPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/"))
			{
				return VetoResult.Allowed;
			}

			var entityName = metadata.Value<string>(Constants.RavenEntityName);

			if (string.IsNullOrEmpty(entityName))
			{
				return VetoResult.Allowed;
			}
			entityName += "/";

			var properties = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

			if (properties == null || properties.Length <= 0) 
				return VetoResult.Allowed;

			var invalidFields = new StringBuilder();

			foreach (var property in properties)
			{
				var propName = ((RavenJValue)property).Value.ToString();
				var uniqueValue = document.Value<string>(propName);
				if(uniqueValue == null)
					continue;
				var checkKey = "UniqueConstraints/" + entityName + propName + "/" +
				               Util.EscapeUniqueValue(uniqueValue);
				var checkDoc = Database.Get(checkKey, transactionInformation);
				if (checkDoc == null) 
					continue;

				var checkId = checkDoc.DataAsJson.Value<string>("RelatedId");

				if (checkId != key)
				{
					invalidFields.Append(property + ", ");
				}
			}

			if (invalidFields.Length > 0)
			{
				invalidFields.Length = invalidFields.Length - 2;
				return VetoResult.Deny("Ensure unique constraint violated for fields: " + invalidFields);
			}

			return VetoResult.Allowed;
		}
开发者ID:remcoros,项目名称:ravendb,代码行数:50,代码来源:UniqueConstraintsPutTrigger.cs

示例15: 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


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