本文整理汇总了C#中ReadOperation类的典型用法代码示例。如果您正苦于以下问题:C# ReadOperation类的具体用法?C# ReadOperation怎么用?C# ReadOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReadOperation类属于命名空间,在下文中一共展示了ReadOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllowRead
public override ReadVetoResult AllowRead(string name, RavenJObject metadata, ReadOperation operation)
{
if (name.EndsWith(RavenFileNameHelper.DownloadingFileSuffix))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
示例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;
}
示例3: AllowRead
public override ReadVetoResult AllowRead(string name, RavenJObject metadata, ReadOperation operation)
{
if (metadata.Value<bool>(SynchronizationConstants.RavenDeleteMarker))
return ReadVetoResult.Ignore;
return ReadVetoResult.Allowed;
}
示例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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例8: ExecuteReadTriggers
public JsonDocument ExecuteReadTriggers(JsonDocument document, TransactionInformation transactionInformation, ReadOperation operation)
{
if(disableReadTriggers.Value)
return document;
return ExecuteReadTriggersOnRead(ProcessReadVetoes(document, transactionInformation, operation),
transactionInformation, operation);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}