/// <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); }
/// <summary> /// 动态创建实例 /// </summary> /// <typeparam name="T">目标类型</typeparam> /// <param name="type">类型</param> /// <param name="parameters">传递给构造函数的参数</param> public static T CreateInstance <T>(Type type, params object[] parameters) { return(Convert.To <T>(Activator.CreateInstance(type, parameters))); }
/// <summary> /// 获取当前应用程序标识 /// </summary> /// <param name="session">用户会话</param> public static T GetApplicationId <T>(this ISession session) { return(Convert.To <T>(Web.Identity.GetValue(ClaimTypes.ApplicationId))); }
/// <summary> /// 获取当前操作人标识 /// </summary> /// <param name="session">用户会话</param> public static T GetUserId <T>(this ISession session) { return(Convert.To <T>(session.UserId)); }