Esempio n. 1
0
        /// <summary>
        /// Indicates whether a navigation would be valid if it were to be performed.
        /// </summary>
        /// <param name="command">The navigation command to test.</param>
        /// <param name="activity">The destination activity, if this is a choice navigation.</param>
        /// <returns>True if the navigation would be valid, false otherwise.</returns>
        /// <remarks>
        /// <para>
        /// This makes a partial copy of the activity tree for processing and attempts to
        /// perform a navigation on that copy.  This may result in poor performance if this
        /// is called many times, but the alternative is to duplicate most of the sequencing
        /// code with lots of special cases for changes of state that should have happened but
        /// could not because of the temporary nature of this request.  This makes it a
        /// maintenance nightmare, for something that should only rarely be called anyway
        /// except in the case of <Mth>LoadTableOfContents</Mth>.
        /// </para>
        /// <para>
        /// The case of <Mth>LoadTableOfContents</Mth> is tough, but steps are taken within
        /// that method to reduce the number of calls to this method to a bare minimum.
        /// </para>
        /// </remarks>
        protected bool IsNavigationValid(NavigationCommand command, Activity activity)
        {
            SeqNav seqNav;

            try
            {
                NavigatorData clone = CloneForNavigationTest();
                Activity      destination;

                if (activity != null)
                {
                    destination = clone.Activities[activity.ActivityId];
                }
                else
                {
                    destination = null;
                }
                if (m_packageFormat == PackageFormat.V1p3)
                {
                    seqNav = new Scorm2004SeqNav(clone);
                }
                else
                {
                    seqNav = new Scorm12SeqNav(clone);
                }
                seqNav.OverallSequencingProcess(command, destination);
            }
            catch (SequencingException)
            {
                // if there was a sequencing exception,
                // this is a failure condition.
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Indicates whether a navigation would be valid if it were to be performed.
        /// </summary>
        /// <param name="command">The navigation command to test.</param>
        /// <param name="activity">The destination activity, if this is a choice navigation.</param>
        /// <returns>True if the navigation would be valid, false otherwise.</returns>
        /// <remarks>
        /// <para>
        /// This makes a partial copy of the activity tree for processing and attempts to
        /// perform a navigation on that copy.  This may result in poor performance if this 
        /// is called many times, but the alternative is to duplicate most of the sequencing
        /// code with lots of special cases for changes of state that should have happened but 
        /// could not because of the temporary nature of this request.  This makes it a 
        /// maintenance nightmare, for something that should only rarely be called anyway 
        /// except in the case of <Mth>LoadTableOfContents</Mth>.
        /// </para>
        /// <para>
        /// The case of <Mth>LoadTableOfContents</Mth> is tough, but steps are taken within
        /// that method to reduce the number of calls to this method to a bare minimum.
        /// </para>
        /// </remarks>
        protected bool IsNavigationValid(NavigationCommand command, Activity activity)
        {
            SeqNav seqNav;

            try
            {
                NavigatorData clone = CloneForNavigationTest();
                Activity destination;

                if(activity != null)
                {
                    destination = clone.Activities[activity.ActivityId];
                }
                else
                {
                    destination = null;
                }
                if(m_packageFormat == PackageFormat.V1p3)
                {
                    seqNav = new Scorm2004SeqNav(clone);
                }
                else
                {
                    seqNav = new Scorm12SeqNav(clone);
                }
                seqNav.OverallSequencingProcess(command, destination);
            }
            catch(SequencingException)
            {
                // if there was a sequencing exception,
                // this is a failure condition.
                return false;
            }
            return true;
        }