Exemplo n.º 1
0
        /// <summary>
        /// 添加变更
        /// </summary>
        /// <param name="expression">属性表达式,范例:t => t.Name</param>
        /// <param name="newValue">新值,范例:newEntity.Name</param>
        protected void AddChange <TProperty, TValue>(Expression <Func <T, TProperty> > expression, TValue newValue)
        {
            var member      = Lambda.GetMemberExpression(expression);
            var name        = Lambda.GetMemberName(member);
            var description = Reflection.GetDisplayNameOrDescription(member.Member);
            var value       = member.Member.GetPropertyValue(this);

            AddChange(name, description, Convert.To <TValue>(value), newValue);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加描述
        /// </summary>
        /// <param name="expression">属性表达式,范例:t => t.Name</param>
        protected void AddDescription <TProperty>(Expression <Func <T, TProperty> > expression)
        {
            var member      = Lambda.GetMember(expression);
            var description = Reflection.GetDisplayNameOrDescription(member);
            var value       = member.GetPropertyValue(this);

            if (Reflection.IsBool(member))
            {
                value = Convert.ToBool(value).Description();
            }
            AddDescription(description, value);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 获取当前应用程序标识
 /// </summary>
 /// <param name="session">用户会话</param>
 public static T GetApplicationId <T>(this ISession session)
 {
     return(Convert.To <T>(Web.Identity.GetValue(ClaimTypes.ApplicationId)));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 获取当前操作人标识
 /// </summary>
 /// <param name="session">用户会话</param>
 public static T GetUserId <T>(this ISession session)
 {
     return(Convert.To <T>(session.UserId));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 获取当前操作人角色标识列表
 /// </summary>
 /// <param name="session">用户会话</param>
 public static List <T> GetRoleIds <T>(this ISession session)
 {
     return(Convert.ToList <T>(Web.Identity.GetValue(ClaimTypes.RoleIds)));
 }