本文整理汇总了C#中RavenJObject.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# RavenJObject.Remove方法的具体用法?C# RavenJObject.Remove怎么用?C# RavenJObject.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RavenJObject
的用法示例。
在下文中一共展示了RavenJObject.Remove方法的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);
}
示例2: AfterPut
public override void AfterPut(string name, long? size, RavenJObject headers)
{
FileSystem.Storage.Batch(accessor =>
{
VersioningConfiguration versioningConfiguration;
if (TryGetVersioningConfiguration(name, headers, accessor, out versioningConfiguration) == false) return;
using (FileSystem.DisableAllTriggersForCurrentThread())
{
var copyHeaders = new RavenJObject(headers);
copyHeaders[VersioningUtil.RavenFileRevisionStatus] = RavenJToken.FromObject("Historical");
copyHeaders[Constants.RavenReadOnly] = true;
copyHeaders.Remove(VersioningUtil.RavenFileRevision);
object parentRevision;
headers.__ExternalState.TryGetValue("Parent-Revision", out parentRevision);
if (parentRevision != null)
{
copyHeaders[VersioningUtil.RavenFileParentRevision] = name + "/revisions/" + parentRevision;
}
object value;
headers.__ExternalState.TryGetValue("Next-Revision", out value);
accessor.PutFile(name + "/revisions/" + value, size, copyHeaders);
}
});
}
示例3: 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);
});
}
示例4: AfterConversionToDocument
public void AfterConversionToDocument(string key, object entity, RavenJObject document, RavenJObject metadata)
{
if (entity is Item == false)
return;
document.Remove("Revision");
}
示例5: 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);
}
}
示例6: AfterPut
public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Etag etag, TransactionInformation transactionInformation)
{
VersioningConfiguration versioningConfiguration;
if (TryGetVersioningConfiguration(key, metadata, out versioningConfiguration) == false)
return;
using (Database.DisableAllTriggersForCurrentThread())
{
var copyMetadata = new RavenJObject(metadata);
copyMetadata[VersioningUtil.RavenDocumentRevisionStatus] = RavenJToken.FromObject("Historical");
copyMetadata[Constants.RavenReadOnly] = true;
copyMetadata.Remove(VersioningUtil.RavenDocumentRevision);
object parentRevision;
metadata.__ExternalState.TryGetValue("Parent-Revision", out parentRevision);
if (parentRevision != null)
{
copyMetadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
copyMetadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
}
object value;
metadata.__ExternalState.TryGetValue("Next-Revision", out value);
Database.Put(key + "/revisions/" + value, null, (RavenJObject)document.CreateSnapshot(), copyMetadata,
transactionInformation);
}
}
示例7: AfterPut
public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Etag etag, TransactionInformation transactionInformation)
{
if (key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase))
return;
var status = document.Value<string>("Status");
if (string.IsNullOrWhiteSpace(status) || !status.Equals("Published", StringComparison.InvariantCultureIgnoreCase))
return;
if (metadata.Value<string>(PublishedVersioningConstants.AtisDocumentRevisionStatus) == "Historical")
return;
using (Database.DisableAllTriggersForCurrentThread())
{
var copyMetadata = new RavenJObject(metadata);
copyMetadata[PublishedVersioningConstants.AtisDocumentRevisionStatus] = RavenJToken.FromObject("Historical");
copyMetadata[Constants.RavenReadOnly] = true;
copyMetadata.Remove(PublishedVersioningConstants.AtisDocumentRevision);
object value;
metadata.__ExternalState.TryGetValue("Next-Revision", out value);
var revisionKey = string.Format("{0}/PublishedRevisions/{1}", key, value);
Database.Put(revisionKey, null, (RavenJObject)document.CreateSnapshot(), copyMetadata, transactionInformation);
log.Debug(() => string.Format("Created published revision with key [{0}]", revisionKey));
}
}
示例8: 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);
}
}
示例9: 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));
}
示例10: CreateDatabase
public HttpJsonRequest CreateDatabase(DatabaseDocument databaseDocument, out RavenJObject doc)
{
if (databaseDocument.Settings.ContainsKey("Raven/DataDir") == false)
throw new InvalidOperationException("The Raven/DataDir setting is mandatory");
var dbname = databaseDocument.Id.Replace("Raven/Databases/", "");
MultiDatabase.AssertValidName(dbname);
doc = RavenJObject.FromObject(databaseDocument);
doc.Remove("Id");
return createRequestForSystemDatabase("/admin/databases/" + Uri.EscapeDataString(dbname), "PUT");
}
示例11: 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);
});
}
示例12: OnPut
public override void OnPut(string key, Stream data, RavenJObject metadata)
{
using (Database.DisableAllTriggersForCurrentThread())
{
metadata.Remove(Constants.RavenReplicationConflict);// you can't put conflicts
var oldVersion = Database.GetStatic(key);
if (oldVersion == null)
return;
if (oldVersion.Metadata[Constants.RavenReplicationConflict] == null)
return;
RavenJArray history = metadata.Value<RavenJArray>(Constants.RavenReplicationHistory) ?? new RavenJArray();
metadata[Constants.RavenReplicationHistory] = history;
var ravenJTokenEqualityComparer = new RavenJTokenEqualityComparer();
// this is a conflict document, holding document keys in the
// values of the properties
var conflictData = oldVersion.Data().ToJObject();
var conflicts = conflictData.Value<RavenJArray>("Conflicts");
if (conflicts == null)
return;
foreach (var prop in conflicts)
{
var id = prop.Value<string>();
Attachment attachment = Database.GetStatic(id);
if(attachment == null)
continue;
Database.DeleteStatic(id, null);
// add the conflict history to the mix, so we make sure that we mark that we resolved the conflict
var conflictHistory = attachment.Metadata.Value<RavenJArray>(Constants.RavenReplicationHistory) ?? new RavenJArray();
conflictHistory.Add(new RavenJObject
{
{Constants.RavenReplicationVersion, attachment.Metadata[Constants.RavenReplicationVersion]},
{Constants.RavenReplicationSource, attachment.Metadata[Constants.RavenReplicationSource]}
});
foreach (var item in conflictHistory)
{
if (history.Any(x => ravenJTokenEqualityComparer.Equals(x, item)))
continue;
history.Add(item);
}
}
}
}
示例13: AfterRename
public override void AfterRename(string name, string renamed, RavenJObject metadata)
{
using (FileSystem.DisableAllTriggersForCurrentThread())
{
FileSystem.Storage.Batch(accessor =>
{
FileVersioningConfiguration versioningConfiguration;
if (actions.TryGetVersioningConfiguration(name, new RavenJObject(), accessor, out versioningConfiguration) == false)
return;
var revisions = accessor.GetFilesStartingWith(name + "/revisions/", 0, int.MaxValue).Where(file => file != null).ToArray();
for (int i = 0; i < revisions.Length; i++)
{
var file = revisions[i];
if (versioningConfiguration.ResetOnRename)
{
if (i == (revisions.Length - 1))
{
// reset file revision
metadata[VersioningUtil.RavenFileRevision] = RavenJToken.FromObject(1);
metadata.Remove(VersioningUtil.RavenFileParentRevision);
accessor.UpdateFileMetadata(renamed, metadata, null);
// rename last existing revision to [renamed]/revisions/1
var revision = file.Name;
accessor.RenameFile(string.Format("{0}/revisions/{1}", name, revision), string.Format("{0}/revisions/{1}", renamed, 1), true);
}
else
{
FileSystem.Files.IndicateFileToDelete(file.FullPath, null);
}
}
else
{
var revision = file.Name;
accessor.RenameFile(string.Format("{0}/revisions/{1}", name, revision), string.Format("{0}/revisions/{1}", renamed, revision), true);
}
}
});
}
}
示例14: OnPut
public override void OnPut(string key, Stream data, RavenJObject metadata)
{
using (Database.DisableAllTriggersForCurrentThread())
{
metadata.Remove(ReplicationConstants.RavenReplicationConflict);// you can't put conflicts
var oldVersion = Database.GetStatic(key);
if (oldVersion == null)
return;
if (oldVersion.Metadata[ReplicationConstants.RavenReplicationConflict] == null)
return;
// this is a conflict document, holding document keys in the
// values of the properties
foreach (var prop in oldVersion.Metadata.Value<RavenJArray>("Conflicts"))
{
Database.DeleteStatic(prop.Value<string>(), null);
}
}
}
示例15: OnPut
public override void OnPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
{
using (Database.DisableAllTriggersForCurrentThread())
{
metadata.Remove(ReplicationConstants.RavenReplicationConflict);// you can't put conflicts
var oldVersion = Database.Get(key, transactionInformation);
if (oldVersion == null)
return;
if (oldVersion.Metadata[ReplicationConstants.RavenReplicationConflict] == null)
return;
RavenJArray history = metadata.Value<RavenJArray>(ReplicationConstants.RavenReplicationHistory) ?? new RavenJArray();
metadata[ReplicationConstants.RavenReplicationHistory] = history;
var ravenJTokenEqualityComparer = new RavenJTokenEqualityComparer();
// this is a conflict document, holding document keys in the
// values of the properties
var conflicts = oldVersion.DataAsJson.Value<RavenJArray>("Conflicts");
if (conflicts == null)
return;
foreach (var prop in conflicts)
{
RavenJObject deletedMetadata;
Database.Delete(prop.Value<string>(), null, transactionInformation, out deletedMetadata);
// add the conflict history to the mix, so we make sure that we mark that we resolved the conflict
var conflictHistory = deletedMetadata.Value<RavenJArray>(ReplicationConstants.RavenReplicationHistory) ?? new RavenJArray();
conflictHistory.Add(new RavenJObject
{
{ReplicationConstants.RavenReplicationVersion, deletedMetadata[ReplicationConstants.RavenReplicationVersion]},
{ReplicationConstants.RavenReplicationSource, deletedMetadata[ReplicationConstants.RavenReplicationSource]}
});
foreach (var item in conflictHistory)
{
if(history.Any(x=>ravenJTokenEqualityComparer.Equals(x, item)))
continue;
history.Add(item);
}
}
}
}