本文整理汇总了C#中Stats.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Stats.GetHashCode方法的具体用法?C# Stats.GetHashCode怎么用?C# Stats.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stats
的用法示例。
在下文中一共展示了Stats.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Output
public void Output(Stats stats)
{
if (CanBeOutput(stats))
{
string note = string.Format("Please note that same stats as current one from this client will not be emailed within next {0}",
emailSetting.NoEmailingTimeSpan.TotalHours >= 1
? string.Format("{0} hour(s)", emailSetting.NoEmailingTimeSpan.TotalHours)
: string.Format("{0} minute(s)", emailSetting.NoEmailingTimeSpan.TotalMinutes));
StringBuilder body = new StringBuilder();
body.AppendLine(template.Render(stats))
.AppendLine()
.AppendLine("---------------------------------------------")
.AppendLine(note);
using (SmtpClient smtp = new SmtpClient(emailSetting.Server, emailSetting.Port))
{
smtp.Send(emailSetting.From,
emailSetting.To,
emailSetting.Subject,
body.ToString());
int hashcode = stats.GetHashCode();
cache.Add(new CacheItem(hashcode.ToString(), string.Empty), new CacheItemPolicy
{
AbsoluteExpiration = DateTimeOffset.UtcNow + emailSetting.NoEmailingTimeSpan
});
}
}
}
示例2: CanBeOutput
protected override bool CanBeOutput(Stats stats)
{
string hashcode = stats.GetHashCode().ToString();
return base.CanBeOutput(stats) && !cache.Contains(hashcode);
}