/// <summary> /// Loads the state for a given task identifier. /// </summary> /// <param name="taskId">The task identifier (a GUID associated with the task).</param> /// <returns>The state.</returns> public static State Load(Guid taskId) { State state = null; if (UIPConfiguration.Config.IsStateCacheEnabled) { state = StateCache.LoadFromCache(taskId); if (state == null) { //State is not there in the cache, so a new state will be created here IStatePersistence spp = StatePersistenceFactory.Create( ); state = Load(spp, taskId); StateCache.PutStateInCache(state, false); } } else { //The cache is disabled, so a new one is created IStatePersistence spp = StatePersistenceFactory.Create( ); state = Load(spp, taskId); } return(state); }
/// <summary> /// Creates the default State object, loading it from the persistence provider. /// </summary> /// <returns>Default state instance of type specified in the configuration file.</returns> public static State Create() { IStatePersistence spp = StatePersistenceFactory.Create(); ObjectTypeSettings typeSettings = UIPConfiguration.Config.DefaultState; State state = Create(spp, typeSettings); if (UIPConfiguration.Config.IsStateCacheEnabled) { StateCache.PutStateInCache(state, true); } return(state); }
/// <summary> /// Creates a State object, loading it from persistence provider. /// </summary> /// <param name="navigatorName">Name of the navigator.</param> /// <returns>State instance of the type specified in the configuration file.</returns> public static State Create(string navigatorName) { // Create a State persistence provider to be used by the state object IStatePersistence spp = StatePersistenceFactory.Create(navigatorName); ObjectTypeSettings typeSettings = UIPConfiguration.Config.GetStateSettings(navigatorName); State state = Create(spp, typeSettings); //Check if the cache is enabled if (UIPConfiguration.Config.IsStateCacheEnabled) { StateCache.PutStateInCache(state, navigatorName, true); } return(state); }