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


C# RavenJObject.JsonDeserialization方法代码示例

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


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

示例1: AllowPut

		public override VetoResult AllowPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
		{
		    if (Database.Name != null && Database.Name != Constants.SystemDatabase)
		        return VetoResult.Allowed;

		    if (key.StartsWith(RavenDatabasesPrefix, StringComparison.InvariantCultureIgnoreCase) == false)
		        return VetoResult.Allowed;

		    var tempPermission = metadata[Constants.AllowBundlesChange];

		    if (tempPermission != null)
		        metadata.Remove(Constants.AllowBundlesChange); // this is a temp marker so do not persist this medatada

		    var bundlesChangesAllowed = tempPermission != null &&
		                                tempPermission.Value<string>()
		                                              .Equals("true", StringComparison.InvariantCultureIgnoreCase);

		    if (bundlesChangesAllowed)
		        return VetoResult.Allowed;

		    var existingDbDoc = Database.Documents.Get(key, transactionInformation);

		    if (existingDbDoc == null)
		        return VetoResult.Allowed;

		    var currentDbDocument = existingDbDoc.DataAsJson.JsonDeserialization<DatabaseDocument>();

		    var currentBundles = new List<string>();
		    string value;
		    if (currentDbDocument.Settings.TryGetValue(Constants.ActiveBundles, out value))
		        currentBundles = value.GetSemicolonSeparatedValues();

		    var newDbDocument = document.JsonDeserialization<DatabaseDocument>();
		    var newBundles = new List<string>();
		    if (newDbDocument.Settings.TryGetValue(Constants.ActiveBundles, out value))
		        newBundles = value.GetSemicolonSeparatedValues();


		    if (currentBundles.Count == newBundles.Count)
		        return VetoResult.Allowed;

		    if (currentBundles.Count == 0)
		        return VetoResult.Allowed;

		    if (currentBundles.TrueForAll(x => newBundles.Contains(x)))
                return VetoResult.Allowed;

		    return VetoResult.Deny(
		        "You should not change 'Raven/ActiveBundles' setting for a database. This setting should be set only once when a database is created. " +
				"If you really need to override it you have to specify {\"" + Constants.AllowBundlesChange +
		        "\": true} in metadata of a database document every time when you send it." + Environment.NewLine +
		        "Current: " + string.Join("; ", currentBundles) + Environment.NewLine +
		        "New: " + string.Join("; '", newBundles));
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:54,代码来源:ActiveBundlesProtection.cs

示例2: AfterCommit

        public override void AfterCommit(string key, RavenJObject document, RavenJObject metadata, Guid etag)
        {
            // When a new clocks config doc is written, reconfigure the active timers

            if (key != ClocksConfig.Id)
                return;

            var config = document.JsonDeserialization<ClocksConfig>();
            if (config == null)
                return;

            var maintainer = Database.StartupTasks.OfType<ClockDocsMaintainer>().SingleOrDefault();
            if (maintainer == null)
                return;

            maintainer.Configure(config);
        }
开发者ID:khalidabuhakmeh,项目名称:ravendb.contrib,代码行数:17,代码来源:ClockDocsConfigTrigger.cs

示例3: AfterCommit

        public override void AfterCommit(string key, RavenJObject document, RavenJObject metadata, Guid etag)
        {
            base.AfterCommit(key, document, metadata, etag);
            var entityName = metadata.Value<string>(Constants.RavenEntityName);
            if (entityName != UpdateCascadeOperation.EntityName) return;
            if (document.Value<string>("Status") != "Pending") return;
            log.Trace("A new operation with id {0} has been put", key);
            var operation = document.JsonDeserialization<UpdateCascadeOperation>();
            var referencedDocId = document.Value<string>("ReferencedDocId");
            var referencedDoc = this.Database.Get(referencedDocId, null);

            if (referencedDoc == null) return;

            if (services.RunningOperationsCoordinator != null)
            {
                services.RunningOperationsCoordinator.TryStartOperation(operation, referencedDoc);
            }
        }
开发者ID:jesuslpm,项目名称:UpdateCascadeBundle,代码行数:18,代码来源:UpdateCascadeOperationPutTrigger.cs

示例4: FromJson

		public static ScriptedPatchRequest FromJson(RavenJObject patchRequestJson)
		{
			return patchRequestJson.JsonDeserialization<ScriptedPatchRequest>();
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:4,代码来源:ScriptedPatchRequest.cs

示例5: GetReplicationMessage

 public static ReplicationMessage GetReplicationMessage(RavenJObject obj)
 {
     return obj.JsonDeserialization<ReplicationMessage>();
 }
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:4,代码来源:ReplicationMessage.cs


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