예제 #1
0
        public void Resolve(SkinResolverContext context, IList <string> skinPaths)
        {
            var    request     = context.RequestContext.HttpContext.Request;
            var    browserInfo = request.Browser;
            bool   isMobile    = IsMobileDevice(browserInfo, request.UserAgent);
            string skin        = request.Cookies.GetSelectedSkin(isMobile);

            if (skin == "Mobile")
            {
                List <string> newSkinPaths = new List <string>(skinPaths.Count);

                foreach (string skinPath in skinPaths)
                {
                    string newSkinPath = string.Format("{0}{1}/{2}", skinPath,
                                                       skinPath.EndsWith("/") ? "Devices" : "/Devices", skin);
                    if (!newSkinPaths.Contains(newSkinPath))
                    {
                        newSkinPaths.Add(newSkinPath);
                    }
                }

                foreach (string skinPath in newSkinPaths)
                {
                    if (!skinPaths.Contains(skinPath))
                    {
                        skinPaths.Add(skinPath);
                    }
                }
            }
        }
예제 #2
0
        public void Resolve(SkinResolverContext context, IList <string> skinPaths)
        {
            bool   isMobile = false;
            string ua       = context.RequestContext.HttpContext.Request.UserAgent ?? "";

            if (!isMobile)
            {
                if (uaRegex.IsMatch(ua))
                {
                    isMobile = true;
                }
            }

            if (!isMobile)
            {
                string[] uaPrefixes = new string[] { "w3c ", "acs-", "alav", "alca", "amoi", "audi", "avan", "benq", "bird", "blac", "blaz", "brew", "cell", "cldc", "cmd-", "dang", "doco", "eric", "hipt", "inno", "ipaq", "java", "jigs", "kddi", "keji", "leno", "lg-c", "lg-d", "lg-g", "lge-", "maui", "maxo", "midp", "mits", "mmef", "mobi", "mot-", "moto", "mwbp", "nec-", "newt", "noki", "oper", "palm", "pana", "pant", "phil", "play", "port", "prox", "qwap", "sage", "sams", "sany", "sch-", "sec-", "send", "seri", "sgh-", "shar", "sie-", "siem", "smal", "smar", "sony", "sph-", "symb", "t-mo", "teli", "tim-", "tosh", "tsm-", "upg1", "upsi", "vk-v", "voda", "wap-", "wapa", "wapi", "wapp", "wapr", "webc", "winw", "winw", "xda", "xda-" };

                foreach (string uaPrefix in uaPrefixes)
                {
                    if (ua.StartsWith(uaPrefix, StringComparison.OrdinalIgnoreCase))
                    {
                        isMobile = true;

                        break;
                    }
                }

                if (isMobile)
                {
                    if (ua.StartsWith("Opera/"))
                    {
                        isMobile = false;
                    }
                }
            }

            if (isMobile)
            {
                List <string> newSkinPaths = new List <string>(skinPaths.Count);

                foreach (string skinPath in skinPaths)
                {
                    newSkinPaths.Add(string.Format("{0}{1}/{2}", skinPath, skinPath.EndsWith("/") ? "Devices" : "/Devices", "Generic"));
                }

                foreach (string skinPath in newSkinPaths)
                {
                    skinPaths.Add(skinPath);
                }
            }
        }
예제 #3
0
 public void Resolve(SkinResolverContext context, IList <string> skinPaths)
 {
     if (context.RequestContext.HttpContext.Request.Browser.Browser.Contains("IE"))
     {
         if (context.RequestContext.HttpContext.Request.Browser.MajorVersion == 7)
         {
             ResolveHacksFolder(skinPaths, "IE7");
         }
         else if (context.RequestContext.HttpContext.Request.Browser.MajorVersion == 6)
         {
             ResolveHacksFolder(skinPaths, "IE6");
         }
     }
 }
예제 #4
0
        public void Resolve(SkinResolverContext context, IList <string> skinPaths)
        {
            string skinsPath = "~" + site.SkinsPath;

            string[] skinNames = context.Skin.Split('/');
            string   skinPath  = string.Format("{0}/{1}", skinsPath, skinNames[0]);

            skinPaths.Add(skinPath);

            if (skinNames.Length > 1)
            {
                for (int i = 1; i < skinNames.Length; i++)
                {
                    skinPaths.Add(skinPath = string.Format("{0}/Layers/{1}", skinPath, skinNames[i]));
                }
            }
        }
        public IEnumerable <IOxiteViewEngine> GenerateViewEngines(SkinResolverContext context, string skin)
        {
            List <IOxiteViewEngine> viewEngines = new List <IOxiteViewEngine>(10);
            List <string>           skinPaths   = new List <string>(20);

            skinPaths.Add("~/");

            if (Default != null)
            {
                Default.Resolve(context, skinPaths);
            }

            foreach (ISkinResolver skinResolver in skinResolvers)
            {
                skinResolver.Resolve(context, skinPaths);
            }

            if (skinPaths.Count > 0)
            {
                skinPaths.Reverse();

                foreach (string skinPath in skinPaths)
                {
                    foreach (IViewEngine viewEngine in ViewEngines.Engines)
                    {
                        if (viewEngine is IOxiteViewEngine)
                        {
                            IOxiteViewEngine viewEngineInstance = (IOxiteViewEngine)container.Resolve(viewEngine.GetType());

                            viewEngineInstance.Skin = skin;

                            viewEngineInstance.SetRootPath(EnsurePath(skinPath));

                            viewEngines.Add(viewEngineInstance);
                        }
                    }
                }
            }

            return(viewEngines);
        }
 public void Resolve(SkinResolverContext skinResolverContext, IList <string> skinPaths)
 {
     // We want to favor the selected skin over the conferences default layer
     skinPaths.Insert(1, "~/Skins/Conferences");
 }