Exemplo n.º 1
0
 public Principal(Identity identity, string[] roles)
     : base(identity, roles)
 {
 }
Exemplo n.º 2
0
        private static void SetUser(HttpContext context, User user, string[] roles, bool isAutheticated)
        {
            Identity identity = new Identity(user, isAutheticated);
            Principal principal = new Principal(identity, roles);
            context.User = principal;

            string langName = string.Empty;
            if (user == null)
            {
                if (HttpContext.Current.Request.UserLanguages != null && HttpContext.Current.Request.UserLanguages.Length > 0 && HttpContext.Current.Request.UserLanguages[0].Length >= 2)
                    langName = HttpContext.Current.Request.UserLanguages[0].Substring(0, 2);
            }
            else
            {
                langName = user.Locale;
            }

            var localeProvider = IoCcontainer.Instance.Resolve<ILocaleProvider>();
            LocaleData locale = localeProvider.GetCultureByName(langName);

            RequestContext.SetValue(RequestContext.LocaleKey, locale);
        }