本文整理汇总了C#中DateTimeOffset.ToEpochTime方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeOffset.ToEpochTime方法的具体用法?C# DateTimeOffset.ToEpochTime怎么用?C# DateTimeOffset.ToEpochTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.ToEpochTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenRoundtripping_ThenSucceeds
public void WhenRoundtripping_ThenSucceeds()
{
var offset = new DateTimeOffset(2011, 2, 7, 4, 30, 20, TimeSpan.Zero);
Assert.Equal(0, offset.Millisecond);
var roundtrip = offset.ToEpochTime().ToDateTimeOffsetFromEpoch();
Assert.Equal(offset, roundtrip);
}
示例2: Arrange
void Arrange(Action specifyExpectedCacheExpiry) {
_cache = Mock.Of<ICache>();
_clock = Mock.Of<IClock>(c => c.UtcNow == DateTimeOffset.Now);
_options = new IdentityServerBearerTokenAuthenticationOptions
{
ValidationResultCacheDuration = TimeSpan.FromMinutes(CacheEvictsTokensAfterMinutes)
};
ExpiryClaimSaysTokenExpiresAt = _clock.UtcNow.AddMinutes(ExpiryClaimSaysTokenExpiresInMinutes);
CacheExpiryEvictsTokenAt = _clock.UtcNow.Add(_options.ValidationResultCacheDuration);
// setup claims to include expiry claim
Claims = new[] {new Claim("bar","baz"), new Claim(ClaimTypes.Expiration,ExpiryClaimSaysTokenExpiresAt.ToEpochTime().ToString()) };
specifyExpectedCacheExpiry();
DebugToConsole(DateTime.Now, ExpiryClaimSaysTokenExpiresAt, _options, CacheExpiryEvictsTokenAt, ExpectedCacheExpiry);
Sut = new InMemoryValidationResultCache(_options, _clock, _cache);
}