コード例 #1
0
        /// <summary>序列化缓存信息</summary>
        /// <returns></returns>
        public virtual AccountCacheInfo Serialize(string appKey, string sessionId, IAccountInfo account)
        {
            AccountCacheInfo accountCache = new AccountCacheInfo();

            accountCache.AccountIdentity = sessionId;

            accountCache.AppKey = appKey;

            accountCache.AccountCacheValue = account.LoginName;

            accountCache.AccountObject = this.SerializeObject(account);

            accountCache.AccountObjectType = KernelContext.ParseObjectType(account.GetType());

            accountCache.IP = account.IP;

            accountCache.HttpUserAgent = HttpContext.Current == null ? string.Empty : HttpContext.Current.Request.UserAgent;

            accountCache.ValidFrom = DateTime.Now;

            accountCache.ValidTo = accountCache.ValidFrom.AddMonths(3);

            accountCache.Date = DateTime.Now;

            return(accountCache);
        }
コード例 #2
0
        /// <summary>反序列化缓存信息信息</summary>
        /// <returns></returns>
        public virtual IAccountInfo Deserialize(AccountCacheInfo accountCache)
        {
            if (accountCache == null)
            {
                return(null);
            }

            return(this.DeserializeObject(accountCache));
        }
コード例 #3
0
 /// <summary>将缓存信息反序列化为帐号信息</summary>
 /// <returns></returns>
 protected abstract IAccountInfo DeserializeObject(AccountCacheInfo accountCache);