Ejemplo n.º 1
0
        internal /*public*/ IndividualDeviceConfig GetDeviceConfig(HttpContext context)
        {
            IndividualDeviceConfig deviceConfig = null;

            #if DEBUG
            if (context.Session != null)
            {
                String var             = "AdapterOverride";
                bool   saveInSession   = true;
                String adapterOverride = (String)context.Session[var];
                if (adapterOverride == null)
                {
                    saveInSession   = false;
                    adapterOverride = (String)context.Request.QueryString[var];
                }
                if (adapterOverride != null &&
                    (deviceConfig = GetDeviceConfig(adapterOverride)) != null)
                {
                    if (saveInSession)
                    {
                        context.Session[var] = adapterOverride;
                    }
                    return(deviceConfig);
                }
            }
            #endif

            foreach (IndividualDeviceConfig candidate in _deviceConfigs.Values)
            {
                if (candidate.DeviceQualifies(context))
                {
                    deviceConfig = candidate;
                    break;
                }
            }

            if (deviceConfig == null && _parent != null)
            {
                deviceConfig = _parent.GetDeviceConfig(context);
            }

            if (deviceConfig == null)
            {
                throw new Exception(
                          SR.GetString(SR.ControlsConfig_NoDeviceConfigRegistered,
                                       context.Request.UserAgent));
            }

            return(deviceConfig);
        }
Ejemplo n.º 2
0
        internal /*public*/ void FixupInheritance(IndividualDeviceConfig referrer, XmlNode configNode)
        {
            if (_fixup == FixupState.FixedUp)
            {
                return;
            }

            if (_fixup == FixupState.FixingUp)
            {
                Debug.Assert(referrer != null);

                // Circular reference
                throw new Exception(SR.GetString(SR.MobileControlsSectionHandler_CircularReference,
                                                 referrer.Name));
            }

            _fixup = FixupState.FixingUp;

            if (ParentConfigName != null)
            {
                Debug.Assert(ParentConfigName.Length != 0 && ParentConfig == null);

                ParentConfig = _controlsConfig.GetDeviceConfig(ParentConfigName);

                if (ParentConfig == null)
                {
                    throw new ConfigurationErrorsException(
                              SR.GetString(SR.MobileControlsSectionHandler_DeviceConfigNotFound,
                                           ParentConfigName),
                              configNode);
                }

                // Make sure parent is fixed up.

                ParentConfig.FixupInheritance(this, configNode);

                if (PageAdapterType == null)
                {
                    PageAdapterType = ParentConfig.PageAdapterType;
                }

                if (DeviceQualifiesPredicate == null)
                {
                    DeviceQualifiesPredicate = ParentConfig.DeviceQualifiesPredicate;
                }

                Debug.Assert(PageAdapterType != null);
                Debug.Assert(DeviceQualifiesPredicate != null);

                // Reset this since we don't need it any longer.
                ParentConfigName = null;
            }

            _fixup = FixupState.FixedUp;
        }