/// <summary> /// 将ID转换成列表 /// </summary> /// <param name="ids">Id标识列表</param> protected IEnumerable <TKey> IdsToList(string ids) { return(Convert.ToList <TKey>(ids)); }
/// <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> /// 将Id转换成主键类型字段 /// </summary> /// <param name="id">主键ID</param> protected TKey ToKey(object id) { var key = Convert.To <TKey>(id); return(key); }
/// <summary> /// 获取当前应用程序标识 /// </summary> /// <param name="session">用户会话</param> public static T GetApplicationId <T>(this ISession session) { return(Convert.To <T>(HttpWeb.Identity.GetValue(IdentityClaimTypes.ApplicationId))); }
/// <summary> /// 获取当前操作人标识 /// </summary> /// <param name="session">用户会话</param> public static T GetUserId <T>(this ISession session) { return(Convert.To <T>(session.UserId)); }
/// <summary> /// 获取当前操作人角色标识列表 /// </summary> /// <param name="session">用户会话</param> public static List <T> GetRoleIds <T>(this ISession session) { return(Convert.ToList <T>(HttpWeb.Identity.GetValue(IdentityClaimTypes.RoleIds))); }
/// <summary> /// 获取枚举值 /// </summary> /// <typeparam name="TResult">返回值类型</typeparam> /// <param name="instance">枚举实例</param> public static TResult Value <TResult>(this Enum instance) { return(Convert.To <TResult>(Value(instance))); }