Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
 /// <summary>
 /// Ends or suspends the current task.
 /// </summary>
 protected virtual void SuspendTask()
 {
     StateCache.RemoveFromCache(State.TaskId);
     State.Clear();
 }
Пример #5
0
 /// <summary>
 /// Completes the task. Completing a task permanently removes any state data for the task.
 /// A completed task cannot be restarted.
 /// </summary>
 public virtual void CompleteTask()
 {
     StateCache.RemoveFromCache(State.TaskId);
     State.Delete();
 }