本文整理汇总了C#中PersonalCacheStruct.TryFind方法的典型用法代码示例。如果您正苦于以下问题:C# PersonalCacheStruct.TryFind方法的具体用法?C# PersonalCacheStruct.TryFind怎么用?C# PersonalCacheStruct.TryFind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PersonalCacheStruct
的用法示例。
在下文中一共展示了PersonalCacheStruct.TryFind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateUserRole
protected override bool CreateUserRole(out IUser user)
{
user = null;
if (UserName.Length < 2 || UserName.Length > 12)
{
ErrorCode = Language.Instance.ErrorCode;
ErrorInfo = Language.Instance.St1005_UserNameNotEnough;
return false;
}
var userCache = new PersonalCacheStruct<GameUserCopy>();
var roleCache = new PersonalCacheStruct<UserRole>();
var userNameCache = new PersonalCacheStruct<UserDescription>();
GameUserCopy gameUser;
if (userCache.TryFindKey(Pid, out gameUser) == LoadingStatus.Success)
{
if (gameUser == null)
{
gameUser = new GameUserCopy
{
UserId = UserId,
PassportId = Pid,
RetailId = RetailID,
NickName = Pid
};
userCache.Add(gameUser);
}
user =new SessionUser(gameUser);
/////////////////Test////////////////////////////
UserDescription description;
if (userNameCache.TryFind(gameUser.PersonalId, r => r.UserId == gameUser.UserId, out description) == LoadingStatus.Success)
{
if (description == null)
{
}
}
////////////////////////////////////////////////////
UserRole role;
if (roleCache.TryFind(gameUser.PersonalId, r => r.RoleName == UserName, out role) == LoadingStatus.Success)
{
if (role == null)
{
role = new UserRole()
{
RoleId = (int)roleCache.GetNextNo(),
UserId = UserId,
RoleName = UserName,
HeadImg = HeadID,
Sex = Sex.ToBool(),
LvNum = 1,
ExperienceNum = 0,
LifeNum = 100,
LifeMaxNum = 100
};
roleCache.Add(role);
gameUser.CurrRoleId = role.RoleId;
}
return true;
}
}
return false;
}