public static DeckTraversalMessage ForDeckTraversal(DeckTraversalModel traversal)
        {
            DeckTraversalMessage message;

            if (traversal is SlideDeckTraversalModel)
            {
                message = new SlideDeckTraversalMessage((SlideDeckTraversalModel)traversal);
            }
            else if (traversal == null)
            {
                throw new ArgumentNullException("traversal");
            }
            else
            {
                throw new ArgumentException("Unknown deck traversal type: " + traversal.ToString());
            }

            // Set the message's predecessor to the current TableOfContents.Entry.
            using (Synchronizer.Lock(traversal.SyncRoot)) {
                if (traversal.Current != null)
                {
                    Message predecessor = message.Predecessor;
                    message.Predecessor = new SlideInformationMessage(traversal.Current.Slide);
                    message.Predecessor.InsertChild(new TableOfContentsEntryMessage(traversal.Current));
                    message.Predecessor.AddOldestPredecessor(predecessor);
                }
                return(message);
            }
        }
 /// <summary>
 /// We receive this message when an instructor navigates between slides in a deck.  There's also one that we
 /// want to ignore that occurs when the instructor opens a new deck but before navigating to a slide in the deck.
 /// </summary>
 /// <param name="stdm"></param>
 /// <returns></returns>
 internal object AddSlideDeckTraversal(CP3Msgs.SlideDeckTraversalMessage stdm)
 {
     //If m.Predecessor.Child is a TOC entry, look up info for RTUPdate there.
     if ((stdm.Predecessor != null) && (stdm.Predecessor.Child != null) &&
         (stdm.Predecessor is CP3Msgs.SlideInformationMessage) &&
         (stdm.Predecessor.Child is CP3Msgs.TableOfContentsEntryMessage) &&
         (stdm.Parent != null) && (stdm.Parent is CP3Msgs.DeckInformationMessage))
     {
         //Debug.WriteLine(stdm.Parent.Parent.ToString(), "*****");
         //We get one of these when a deck is first opened, but before the instructor navigates to it.  Filter it out
         //by remembering the current deck ID and ignoring messages for decks other than the current.
         if ((currentDeckId == Guid.Empty) || (currentDeckId.Equals((Guid)stdm.Parent.TargetId)))
         {
             currentSlideId = (Guid)stdm.Predecessor.TargetId;
             currentDeckId  = (Guid)stdm.Parent.TargetId;
             RTUpdate rtu = this.toc.GetRtUpdate((Guid)stdm.Predecessor.Child.TargetId);
             return(rtu);
         }
     }
     else
     {
         //No warning because this happens when a new SS deck is created upon receipt of the first submission.
         Debug.WriteLine("A SlideDeckTraversal is being ignored because it lacks the expected message graph.");
     }
     return(null);
 }
        public static DeckTraversalMessage ForDeckTraversal(DeckTraversalModel traversal)
        {
            DeckTraversalMessage message;
            if(traversal is SlideDeckTraversalModel)
                message = new SlideDeckTraversalMessage((SlideDeckTraversalModel) traversal);
            else if(traversal == null)
                throw new ArgumentNullException("traversal");
            else
                throw new ArgumentException("Unknown deck traversal type: " + traversal.ToString());

            // Set the message's predecessor to the current TableOfContents.Entry.
            using(Synchronizer.Lock(traversal.SyncRoot)) {
                if( traversal.Current != null ) {
                    Message predecessor = message.Predecessor;
                    message.Predecessor = new SlideInformationMessage( traversal.Current.Slide );
                    message.Predecessor.InsertChild( new TableOfContentsEntryMessage( traversal.Current ) );
                    message.Predecessor.AddOldestPredecessor( predecessor );
                }
                return message;
            }
        }