Esempio n. 1
0
 /// <summary>
 ///     将ID转换成列表
 /// </summary>
 /// <param name="ids">Id标识列表</param>
 protected IEnumerable <TKey> IdsToList(string ids)
 {
     return(Convert.ToList <TKey>(ids));
 }
Esempio n. 2
0
 /// <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)));
 }
Esempio n. 3
0
        /// <summary>
        ///     将Id转换成主键类型字段
        /// </summary>
        /// <param name="id">主键ID</param>
        protected TKey ToKey(object id)
        {
            var key = Convert.To <TKey>(id);

            return(key);
        }
Esempio n. 4
0
 /// <summary>
 ///     获取当前应用程序标识
 /// </summary>
 /// <param name="session">用户会话</param>
 public static T GetApplicationId <T>(this ISession session)
 {
     return(Convert.To <T>(HttpWeb.Identity.GetValue(IdentityClaimTypes.ApplicationId)));
 }
Esempio n. 5
0
 /// <summary>
 ///     获取当前操作人标识
 /// </summary>
 /// <param name="session">用户会话</param>
 public static T GetUserId <T>(this ISession session)
 {
     return(Convert.To <T>(session.UserId));
 }
Esempio n. 6
0
 /// <summary>
 ///     获取当前操作人角色标识列表
 /// </summary>
 /// <param name="session">用户会话</param>
 public static List <T> GetRoleIds <T>(this ISession session)
 {
     return(Convert.ToList <T>(HttpWeb.Identity.GetValue(IdentityClaimTypes.RoleIds)));
 }
Esempio n. 7
0
 /// <summary>
 ///     获取枚举值
 /// </summary>
 /// <typeparam name="TResult">返回值类型</typeparam>
 /// <param name="instance">枚举实例</param>
 public static TResult Value <TResult>(this Enum instance)
 {
     return(Convert.To <TResult>(Value(instance)));
 }