本文整理汇总了C#中System.Stream.ToHexString方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ToHexString方法的具体用法?C# Stream.ToHexString怎么用?C# Stream.ToHexString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Stream
的用法示例。
在下文中一共展示了Stream.ToHexString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadHighestIndexedProjectionStreamSequenceAsync
public Task<int> ReadHighestIndexedProjectionStreamSequenceAsync(Stream stream)
{
lock (_projectionIndexes)
{
List<long> projection;
if (_projectionIndexes.TryGetValue(stream.ToHexString(), out projection))
return Task.FromResult(projection.Count);
}
return Task.FromResult(0);
}
示例2: ReadIndexedProjectionStreamAsync
public Task ReadIndexedProjectionStreamAsync(Stream stream, int initialSequence, int count, Action<IPersistedRawEvent> readCallback, CancellationToken ct)
{
lock (_projectionIndexes)
{
List<long> projection;
if (_projectionIndexes.TryGetValue(stream.ToHexString(), out projection))
{
IEnumerable<PersistedRawEvent> events;
lock (_events)
{
events = from s in projection
join e in _events on s equals e.GlobalSequence
orderby e.GlobalSequence
select e;
if (initialSequence > 0)
events = events.Skip(initialSequence - 1);
if (count >= 0)
events = events.Take(count);
events = events.ToList();
}
foreach (var e in events)
{
if (ct.IsCancellationRequested)
break;
readCallback(e);
}
}
}
return Unit.GetCompletedTask();
}
示例3: ReadHighestIndexedProjectionGlobalSequenceAsync
public Task<long> ReadHighestIndexedProjectionGlobalSequenceAsync(Stream stream)
{
lock (_projectionIndexes)
{
List<long> projection;
if (_projectionIndexes.TryGetValue(stream.ToHexString(), out projection))
return Task.FromResult(projection.LastOrDefault());
}
return Task.FromResult(0L);
}
示例4: ReadProjectionCheckpointAsync
public Task<long> ReadProjectionCheckpointAsync(Stream stream)
{
lock (_projectionCheckpoints)
{
long checkpoint;
if (_projectionCheckpoints.TryGetValue(stream.ToHexString(), out checkpoint))
return Task.FromResult(checkpoint);
}
return Task.FromResult(0L);
}
示例5: WriteProjectionCheckpointAsync
public Task WriteProjectionCheckpointAsync(Stream stream, long globalSequence)
{
lock (_projectionCheckpoints)
{
_projectionCheckpoints[stream.ToHexString()] = globalSequence;
}
return Unit.GetCompletedTask();
}
示例6: WriteProjectionIndexAsync
public Task WriteProjectionIndexAsync(Stream stream, int expectedSequence, IReadOnlyCollection<long> globalSequences)
{
lock (_projectionIndexes)
{
List<long> projection;
var key = stream.ToHexString();
if (!_projectionIndexes.TryGetValue(key, out projection))
_projectionIndexes.Add(key, projection = new List<long>());
if (projection.Count != expectedSequence)
throw new UnexpectedStreamSequenceException();
if (globalSequences.Intersect(projection).Any())
throw new DuplicatedEntryException();
lock (_events)
{
projection.AddRange(globalSequences);
}
}
return Unit.GetCompletedTask();
}
示例7: ClearProjectionIndexAsync
public Task ClearProjectionIndexAsync(Stream stream)
{
var key = stream.ToHexString();
lock (_projectionCheckpoints)
{
if (_projectionCheckpoints.ContainsKey(key))
_projectionCheckpoints.Remove(key);
}
lock (_projectionIndexes)
{
if (_projectionIndexes.ContainsKey(key))
_projectionIndexes.Remove(key);
}
return Unit.GetCompletedTask();
}