本文整理汇总了C#中Activity.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Activity.GetHashCode方法的具体用法?C# Activity.GetHashCode怎么用?C# Activity.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Activity
的用法示例。
在下文中一共展示了Activity.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateProfileUpdatedActivity
/// <summary>
/// Make a profile updated joined activity object from the more generic database activity object
/// </summary>
/// <param name="activity"></param>
/// <returns></returns>
private ProfileUpdatedActivity GenerateProfileUpdatedActivity(Activity activity)
{
var cacheKey = string.Concat(CacheKeys.Activity.StartsWith, "GenerateProfileUpdatedActivity-", activity.GetHashCode());
return _cacheService.CachePerRequest(cacheKey, () =>
{
var dataPairs = ActivityBase.UnpackData(activity);
if (!dataPairs.ContainsKey(ProfileUpdatedActivity.KeyUserId))
{
// Log the problem then skip
_loggingService.Error($"A profile updated activity record with id '{activity.Id}' has no user id in its data.");
return null;
}
var userId = dataPairs[ProfileUpdatedActivity.KeyUserId];
var user = _context.MembershipUser.FirstOrDefault(x => x.Id == new Guid(userId));
if (user == null)
{
// Log the problem then skip
_loggingService.Error($"A profile updated activity record with id '{activity.Id}' has a user id '{userId}' that is not found in the user table.");
return null;
}
return new ProfileUpdatedActivity(activity, user);
});
}
示例2: GenerateBadgeActivity
/// <summary>
/// Make a badge activity object from the more generic database activity object
/// </summary>
/// <param name="activity"></param>
/// <returns></returns>
private BadgeActivity GenerateBadgeActivity(Activity activity)
{
//System.Reflection.MethodBase.GetCurrentMethod().Name
var cacheKey = string.Concat(CacheKeys.Activity.StartsWith, "GenerateBadgeActivity-", activity.GetHashCode());
return _cacheService.CachePerRequest(cacheKey, () =>
{
// Get the corresponding badge
var dataPairs = ActivityBase.UnpackData(activity);
if (!dataPairs.ContainsKey(BadgeActivity.KeyBadgeId))
{
// Log the problem then skip
_loggingService.Error($"A badge activity record with id '{activity.Id}' has no badge id in its data.");
return null;
}
var badgeId = dataPairs[BadgeActivity.KeyBadgeId];
var badge = _badgeService.Get(new Guid(badgeId));
if (badge == null)
{
// Log the problem then skip
_loggingService.Error($"A badge activity record with id '{activity.Id}' has a badge id '{badgeId}' that is not found in the badge table.");
return null;
}
var userId = dataPairs[BadgeActivity.KeyUserId];
var user = _context.MembershipUser.FirstOrDefault(x => x.Id == new Guid(userId));
if (user == null)
{
// Log the problem then skip
_loggingService.Error($"A badge activity record with id '{activity.Id}' has a user id '{userId}' that is not found in the user table.");
return null;
}
return new BadgeActivity(activity, badge, user);
});
}