/// <summary>
        /// Returns an instance of <see cref="Microsoft.ApplicationBlocks.UIProcess.IStatePersistence"/>
        /// for the given <see cref="Microsoft.ApplicationBlocks.UIProcess.StatePersistenceProviderSettings"/>.
        /// </summary>
        /// <param name="providerSettings">The settings for  state persistence.</param>
        /// <returns>The instance of IStatePersistence. It gets this from the internal cache, if possible.</returns>
        public static IStatePersistence Create(StatePersistenceProviderSettings providerSettings)
        {
            string            statePersistenceKey = providerSettings.Type + "," + providerSettings.Assembly;
            IStatePersistence spp = (IStatePersistence)_statePersistenceCache[statePersistenceKey];

            if (spp == null)
            {
                try
                {
                    //  now create instance based on that type info
                    spp = (IStatePersistence)GenericFactory.Create(providerSettings);

                    //  pass in parameters to spp init method.  this is where spp's find data they need such as
                    //  connection strings, etc.
                    spp.Init(providerSettings.AdditionalAttributes);
                }
                catch (Exception e)
                {
                    throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionCantCreateStatePersistenceProvider, providerSettings.Type) + UIPException.GetFirstExceptionMessage(e), e);
                }

                //  lock collection
                lock (_statePersistenceCache.SyncRoot)
                    _statePersistenceCache[statePersistenceKey] = spp;
            }

            //  return it
            return(spp);
        }
        /// <summary>
        /// Returns an instance of IStatePersistence according to the navigator used.
        /// This is an optimization to avoid having to look up type information in the config object each time; instead, it uses the navigator name.
        /// </summary>
        /// <param name="navigator">The navigator name.</param>
        /// <returns>An instance of IStatePersistence of the specified type. It gets this from the internal cache, if possible.</returns>
        public static IStatePersistence Create(string navigator)
        {
            StatePersistenceProviderSettings providerSettings = UIPConfiguration.Config.GetPersistenceProviderSettings(navigator);

            if (providerSettings == null)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionStatePersistenceProviderConfigNotFound, navigator));
            }

            return(Create(providerSettings));
        }
        private void LoadViewManagementObjects(XmlNode configNode)
        {
            //Get the configured IViewManager object types
            ObjectTypeSettings typedObject;

            foreach (XmlNode objectTypeNode in configNode.SelectSingleNode(NodeObjectTypesXPath).ChildNodes)
            {
                switch (objectTypeNode.LocalName)
                {
                case NodeILayoutManagerXPath:
                    typedObject = new ObjectTypeSettings(objectTypeNode);
                    _iLayoutManagerCollection.Add(typedObject.Name, typedObject);
                    break;

                case NodeIViewManagerXPath:
                    typedObject = new ObjectTypeSettings(objectTypeNode);
                    _iViewManagerCollection.Add(typedObject.Name, typedObject);
                    if (IsDefault(objectTypeNode))
                    {
                        _defaultViewManager = typedObject;
                    }
                    break;

                case NodeStateXPath:
                    typedObject = new ObjectTypeSettings(objectTypeNode);
                    _stateCollection.Add(typedObject.Name, typedObject);
                    if (IsDefault(objectTypeNode))
                    {
                        _defaultState = typedObject;
                    }
                    break;

                case NodeControllerXpath:
                    typedObject = new ObjectTypeSettings(objectTypeNode);
                    _controllerCollection.Add(typedObject.Name, typedObject);
                    break;

                case NodePersistProviderXPath:
                    typedObject = new StatePersistenceProviderSettings(objectTypeNode);
                    _statePersistenceCollection.Add(typedObject.Name, typedObject);
                    if (IsDefault(objectTypeNode))
                    {
                        _defaultStatePersistence = (StatePersistenceProviderSettings)typedObject;
                    }
                    break;
                }
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public UIPConfigSettings( )
 {
     //Init the hashtables
     _iLayoutManagerCollection   = new HybridDictionary();
     _iViewManagerCollection     = new HybridDictionary();
     _stateCollection            = new HybridDictionary();
     _controllerCollection       = new HybridDictionary();
     _statePersistenceCollection = new HybridDictionary();
     _viewByNameCollection       = new Hashtable();
     _navigatorCollection        = new HybridDictionary();
     _globalSharedTransitions    = new HybridDictionary();
     _hostedControlsCollection   = new HybridDictionary();
     _isStateCacheEnabled        = true;
     _defaultViewManager         = null;
     _defaultState            = null;
     _defaultStatePersistence = null;
     _allowBackButton         = true;
 }