本文整理汇总了C#中ReadOperation类的典型用法代码示例。如果您正苦于以下问题:C# ReadOperation类的具体用法?C# ReadOperation怎么用?C# ReadOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReadOperation类属于命名空间,在下文中一共展示了ReadOperation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AllowRead
public override ReadVetoResult AllowRead(string name, RavenJObject metadata, ReadOperation operation)
{
if (name.EndsWith(RavenFileNameHelper.DownloadingFileSuffix))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:7,代码来源:HideDownloadingFileTrigger.cs
示例2: AllowRead
public override ReadVetoResult AllowRead(string key, RavenJObject metadata, ReadOperation operation, TransactionInformation transactionInformation)
{
// This trigger is only for simple query operations
if (key == null || operation != ReadOperation.Query)
return ReadVetoResult.Allowed;
// Don't do anything if temporal versioning is inactive for this document type
if (!Database.IsTemporalVersioningEnabled(key, metadata))
return ReadVetoResult.Allowed;
// If an effective date was passed in, then use it.
DateTimeOffset effective;
var headerValue = CurrentOperationContext.Headers.Value[TemporalMetadata.RavenTemporalEffective];
if (headerValue == null || !DateTimeOffset.TryParse(headerValue, null, DateTimeStyles.RoundtripKind, out effective))
{
// If no effective data passed, return as stored.
return ReadVetoResult.Allowed;
}
// Return the requested effective date in the metadata.
var temporal = metadata.GetTemporalMetadata();
temporal.Effective = effective;
// Return the result if it's the active revision, or skip it otherwise.
return temporal.Status == TemporalStatus.Revision &&
temporal.EffectiveStart <= effective && effective < temporal.EffectiveUntil &&
!temporal.Deleted
? ReadVetoResult.Allowed
: ReadVetoResult.Ignore;
}
开发者ID:jggutierrez,项目名称:RavenDB-TemporalVersioning,代码行数:30,代码来源:TemporalVersioningQueryTrigger.cs
示例3: AllowRead
public override ReadVetoResult AllowRead(string name, RavenJObject metadata, ReadOperation operation)
{
if (metadata.Value<bool>(SynchronizationConstants.RavenDeleteMarker))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:7,代码来源:HideDeletingFilesTrigger.cs
示例4: AllowRead
public override ReadVetoResult AllowRead(string key, Stream data, RavenJObject metadata, ReadOperation operation)
{
RavenJToken value;
if (metadata.TryGetValue("Raven-Delete-Marker", out value))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:neiz,项目名称:ravendb,代码行数:7,代码来源:HideVirtuallyDeletedAttachmentsReadTrigger.cs
示例5: ProcessReadVetoes
public JsonDocument ProcessReadVetoes(JsonDocument document, TransactionInformation transactionInformation, ReadOperation operation)
{
if (document == null)
return document;
foreach (var readTrigger in triggers)
{
var readVetoResult = readTrigger.AllowRead(document.Key, document.DataAsJson ?? document.Projection, document.Metadata, operation, transactionInformation);
switch (readVetoResult.Veto)
{
case ReadVetoResult.ReadAllow.Allow:
break;
case ReadVetoResult.ReadAllow.Deny:
return new JsonDocument
{
DataAsJson = new JObject(),
Metadata = new JObject(
new JProperty("Raven-Read-Veto", new JObject(new JProperty("Reason", readVetoResult.Reason),
new JProperty("Trigger", readTrigger.ToString())
))
)
};
case ReadVetoResult.ReadAllow.Ignore:
return null;
default:
throw new ArgumentOutOfRangeException(readVetoResult.Veto.ToString());
}
}
return document;
}
开发者ID:algida,项目名称:ravendb,代码行数:30,代码来源:DocumentRetriever.cs
示例6: OnRead
public override void OnRead(string key, RavenJObject document, RavenJObject metadata, ReadOperation operation, TransactionInformation transactionInformation)
{
var name = document["name"];
if (name != null)
{
document["name"] = new RavenJValue(name.Value<string>().ToUpper());
}
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:8,代码来源:UpperCaseNamesTrigger.cs
示例7: AllowRead
public override ReadVetoResult AllowRead(string key, Stream data, RavenJObject metadata, ReadOperation operation)
{
if (key.All(char.IsUpper))
return ReadVetoResult.Ignore;
if (key.Any(char.IsUpper))
return ReadVetoResult.Deny("You don't get to read this attachment");
return ReadVetoResult.Allowed;
}
开发者ID:cocytus,项目名称:ravendb,代码行数:8,代码来源:AttachmentReadTrigger.cs
示例8: ExecuteReadTriggers
public JsonDocument ExecuteReadTriggers(JsonDocument document, TransactionInformation transactionInformation, ReadOperation operation)
{
if(disableReadTriggers.Value)
return document;
return ExecuteReadTriggersOnRead(ProcessReadVetoes(document, transactionInformation, operation),
transactionInformation, operation);
}
开发者ID:vinone,项目名称:ravendb,代码行数:8,代码来源:DocumentRetriever.cs
示例9: AllowRead
public override ReadVetoResult AllowRead(string key, byte[] data, Newtonsoft.Json.Linq.JObject metadata, ReadOperation operation)
{
if (key.All(char.IsUpper))
return ReadVetoResult.Ignore;
if (key.Any(char.IsUpper))
return ReadVetoResult.Deny("You don't get to read this attachment");
return ReadVetoResult.Allowed;
}
开发者ID:vinone,项目名称:ravendb,代码行数:8,代码来源:AttachmentReadTrigger.cs
示例10: AllowRead
public override ReadVetoResult AllowRead(string key, Json.Linq.RavenJObject metadata, ReadOperation operation, Abstractions.Data.TransactionInformation transactionInformation)
{
if (operation == ReadOperation.Index && metadata.ContainsKey(Constants.RavenReplicationConflictDocument))
{
return ReadVetoResult.Ignore;
}
return ReadVetoResult.Allowed;
}
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:PreventIndexingConflictDocumentsReadTrigger.cs
示例11: 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
示例12: AllowRead
public override ReadVetoResult AllowRead(string key, JObject document, JObject metadata, ReadOperation operation, TransactionInformation transactionInformation)
{
if(key == null)
return ReadVetoResult.Allowed;
if (key.StartsWith("Raven/") && operation == ReadOperation.Query)
return ReadVetoResult.Ignore; // hide Raven's documentation from queries
return ReadVetoResult.Allowed;
}
开发者ID:kenegozi,项目名称:ravendb,代码行数:8,代码来源:FilterRavenInternalDocumentsReadTrigger.cs
示例13: AllowRead
public override ReadVetoResult AllowRead(string key, byte[] data, JObject metadata, ReadOperation operation)
{
if (ReplicationContext.IsInReplicationContext)
return ReadVetoResult.Allowed;
JToken value;
if (metadata.TryGetValue("Raven-Delete-Marker", out value))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:vinone,项目名称:ravendb,代码行数:9,代码来源:HideVirtuallyDeletedAttachmentsReadTrigger.cs
示例14: AllowRead
public override ReadVetoResult AllowRead(string key, RavenJObject metadata, ReadOperation operation, TransactionInformation transactionInformation)
{
// always reset these
_temporalVersioningEnabled.Value = false;
_effectiveVersionKey.Value = null;
_now.Value = SystemTime.UtcNow;
if (key == null)
return ReadVetoResult.Allowed;
// This trigger is only for load operations
if (operation != ReadOperation.Load)
return ReadVetoResult.Allowed;
// Don't do anything if temporal versioning is inactive for this document type
_temporalVersioningEnabled.Value = Database.IsTemporalVersioningEnabled(key, metadata);
if (!_temporalVersioningEnabled.Value)
return ReadVetoResult.Allowed;
// Only operate on current temporal documents
var temporal = metadata.GetTemporalMetadata();
if (temporal.Status != TemporalStatus.Current)
return ReadVetoResult.Allowed;
// If an effective date was passed in, then use it.
DateTimeOffset effective;
var headerValue = CurrentOperationContext.Headers.Value[TemporalMetadata.RavenTemporalEffective];
if (headerValue == null || !DateTimeOffset.TryParse(headerValue, null, DateTimeStyles.RoundtripKind, out effective))
{
// If no effective data passed, return current data, as stored, effective now.
temporal.Effective = _now.Value;
return ReadVetoResult.Allowed;
}
// Return the requested effective date in the metadata.
temporal.Effective = effective;
// If the current document is already in range, just return it
if (temporal.EffectiveStart <= effective && effective < temporal.EffectiveUntil)
return ReadVetoResult.Allowed;
// Load the history doc
Etag historyEtag;
var history = Database.GetTemporalHistoryFor(key, transactionInformation, out historyEtag);
// Find the revision that is effective at the date requested
var effectiveRevisionInfo = history.Revisions.FirstOrDefault(x => x.Status == TemporalStatus.Revision &&
x.EffectiveStart <= effective &&
x.EffectiveUntil > effective);
// Return nothing if there is no revision at the effective date
if (effectiveRevisionInfo == null)
return ReadVetoResult.Ignore;
// Hold on to the key so we can use it later in OnRead
_effectiveVersionKey.Value = effectiveRevisionInfo.Key;
return ReadVetoResult.Allowed;
}
开发者ID:jggutierrez,项目名称:RavenDB-TemporalVersioning,代码行数:57,代码来源:TemporalVersioningLoadTrigger.cs
示例15: AllowRead
public override ReadVetoResult AllowRead(string name, RavenJObject metadata, ReadOperation operation)
{
if (metadata.Value<bool>(SynchronizationConstants.RavenDeleteMarker))
return ReadVetoResult.Ignore;
if (name.EndsWith(RavenFileNameHelper.DeletingFileSuffix)) // such file should already have RavenDeleteMarker, but just in case
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:10,代码来源:HideDeletingFilesTrigger.cs
示例16: AllowRead
public override ReadVetoResult AllowRead(string key, RavenJObject metadata, ReadOperation operation,
TransactionInformation transactionInformation)
{
if(metadata == null)
return ReadVetoResult.Allowed; // this is a projection, it is allowed
RavenJToken value;
if (metadata.TryGetValue("Raven-Delete-Marker", out value))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:10,代码来源:HideVirtuallyDeletedDocumentsReadTrigger.cs
示例17: AllowRead
public override ReadVetoResult AllowRead(string key, RavenJObject metadata, ReadOperation operation, TransactionInformation transactionInformation)
{
if (operation != ReadOperation.Index)
return ReadVetoResult.Allowed;
if (metadata.Value<string>(VersioningUtil.RavenDocumentRevisionStatus) == "Historical" && Database.IsVersioningActive(metadata))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:royra,项目名称:ravendb,代码行数:10,代码来源:HideVersionedDocumentsFromIndexingTrigger.cs
示例18: AllowRead
public override ReadVetoResult AllowRead(string key, Raven.Json.Linq.RavenJObject metadata, ReadOperation operation, Raven.Abstractions.Data.TransactionInformation transactionInformation)
{
if (operation != ReadOperation.Index)
return ReadVetoResult.Allowed;
if (metadata.Value<string>(PublishedVersioningConstants.AtisDocumentRevisionStatus) == "Historical")
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:SeanFeldman,项目名称:RavenDB-Spikes,代码行数:10,代码来源:HidePublishedVersioniningDocumentsFromIndexingTrigger.cs
示例19: AllowRead
public override ReadVetoResult AllowRead(string name, RavenJObject metadata, ReadOperation operation)
{
if (operation != ReadOperation.Index)
return ReadVetoResult.Allowed;
if (metadata.Value<string>(VersioningUtil.RavenFileRevisionStatus) == "Historical" && FileSystem.IsVersioningActive(name))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:10,代码来源:HideVersionedFilesFromIndexingTrigger.cs
示例20: 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
注:本文中的ReadOperation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论