示例#1
0
        public EntityBase()
        {
            var impFactory = GetIMPFactory();

            if (impFactory == null)
            {
                if (_impGenerateServiceFactory != null)
                {
                    _imp = _impGenerateServiceFactory.Create().Generate <T>();
                }
                else
                {
                    var di = ContextContainer.GetValue <IDIContainer>("DI");
                    if (di == null)
                    {
                        _imp = DIContainerContainer.Get <T>();
                    }
                    else
                    {
                        _imp = di.Get <T>();
                    }
                }
            }
            else
            {
                _imp = impFactory.Create();
            }
        }
示例#2
0
        public static DateTime ToCurrentUserTimeZone(this DateTime time)
        {
            //获取当前用户的时区
            var timeZone = ContextContainer.GetValue <int>(ContextTypes.CurrentUserTimezoneOffset);

            return(time.AddHours(timeZone));
        }
示例#3
0
 /// <summary>
 /// 获取基于当前用户语言的错误内容(同步)
 /// </summary>
 /// <param name="exception"></param>
 /// <returns></returns>
 public static string GetCurrentLcidMessageSync(this Exception exception)
 {
     if (exception is UtilityException)
     {
         var lcid = ContextContainer.GetValue <int>(ContextTypes.CurrentUserLcid);
         return(((UtilityException)exception).Fragment.GetLanguageTextSync(lcid));
     }
     else
     {
         return(exception.Message);
     }
 }
示例#4
0
 /// <summary>
 /// 获取基于当前用户语言的错误内容
 /// </summary>
 /// <param name="exception"></param>
 /// <returns></returns>
 public static async Task <string> GetCurrentLcidMessage(this Exception exception)
 {
     if (exception is UtilityException)
     {
         var lcid = ContextContainer.GetValue <int>(ContextTypes.CurrentUserLcid);
         return(await((UtilityException)exception).Fragment.GetLanguageText(lcid));
     }
     else
     {
         return(await Task.FromResult(exception.Message));
     }
 }