本文整理匯總了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);
});
}