本文整理汇总了C#中System.Guid.ToBigInteger方法的典型用法代码示例。如果您正苦于以下问题:C# Guid.ToBigInteger方法的具体用法?C# Guid.ToBigInteger怎么用?C# Guid.ToBigInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Guid
的用法示例。
在下文中一共展示了Guid.ToBigInteger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public IEnumerable<IStreamQueryPartition<Guid>> Build(
Guid lowerBoundExclusive,
Guid upperBoundInclusive,
int numberOfPartitions)
{
var upperBigIntInclusive = upperBoundInclusive.ToBigInteger();
var lowerBigIntExclusive = lowerBoundExclusive.ToBigInteger();
var space = upperBigIntInclusive - lowerBigIntExclusive;
foreach (var i in Enumerable.Range(0, numberOfPartitions))
{
var lower = lowerBigIntExclusive + (i*(space/numberOfPartitions));
var upper = lowerBigIntExclusive + ((i + 1)*(space/numberOfPartitions));
if (i == numberOfPartitions - 1)
{
upper = upperBigIntInclusive;
}
yield return new StreamQueryPartition<Guid>
{
LowerBoundExclusive = lower.ToGuid(),
UpperBoundInclusive = upper.ToGuid()
};
}
}
示例2: TestGuidRoundTrip
private static void TestGuidRoundTrip(Guid guid)
{
Console.WriteLine(guid);
guid.ToBigInteger().ToGuid().Should().Be(guid);
}