本文整理汇总了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));
}
示例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);
}
示例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);
}
}
示例4: FromJson
public static ScriptedPatchRequest FromJson(RavenJObject patchRequestJson)
{
return patchRequestJson.JsonDeserialization<ScriptedPatchRequest>();
}
示例5: GetReplicationMessage
public static ReplicationMessage GetReplicationMessage(RavenJObject obj)
{
return obj.JsonDeserialization<ReplicationMessage>();
}