Click here to Skip to main content
15,886,072 members
Articles / Web Development / ASP.NET

Navigational Workflows Unleashed in WWF/ASP.NET 3.5

Rate me:
Please Sign up or sign in to vote.
4.97/5 (42 votes)
21 Oct 2008CPOL18 min read 224.9K   1.6K   165  
Case-study on the internals of a Navigational Workflow engine for a fictional dating website called “World Wide Dating”.
using System;
using System.Workflow.Activities;

namespace DateSiteNavigation
{
    /// <summary>
    /// A local service that exposes events used by both the host application
    /// and the navigational workflow to communicate with each other.
    /// </summary>
	public class NavigationService : INavigationService 
	{
        /// <summary>
        /// Sent to the host application indicating the page to go to.
        /// </summary>
        public event EventHandler<PageToGoToEventArgs> PageToGoToReceived;

        /// <summary>
        /// Sent to the host application indicating if the navigational workflow is in sync,
        /// and if not it contains the information necessary to synchronize it.
        /// </summary>
        public event EventHandler<OutgoingSynchronizeEventArgs> OutgoingSynchronizeReceived;

        #region INavigationService Members

        public event EventHandler<ExternalDataEventArgs> Previous;
        public event EventHandler<ExternalDataEventArgs> Next;
        public event EventHandler<ExternalDataEventArgs> Rehydrated;
        public event EventHandler<IncomingSynchronizeEventArgs> IncomingSynchronize;
        public event EventHandler<ErrorEventArgs> Error;
        public event EventHandler<ExternalDataEventArgs> SkipToBasics;
        public event EventHandler<ExternalDataEventArgs> SkipToAppearance;
        public event EventHandler<ExternalDataEventArgs> SkipToLifestyle;
        public event EventHandler<ExternalDataEventArgs> SkipToInterests;
        public event EventHandler<ExternalDataEventArgs> SkipToComplete;

        public void OnPageToGoTo(PageToGoToEventArgs args)
        {
            if (PageToGoToReceived != null)
            {
                PageToGoToReceived(this, args);
            }
        }

        public void OnOutgoingSynchronize(OutgoingSynchronizeEventArgs args)
        {
            if (OutgoingSynchronizeReceived != null)
            {
                OutgoingSynchronizeReceived(this, args);
            }
        }

        #endregion

        /// <summary>
        /// Wrapper for the host app to call the Previous event.
        /// </summary>
        /// <param name="args"></param>
        public void OnPrevious(ExternalDataEventArgs args)
        {
            if (Previous != null)
            {
                Previous(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the Next event.
        /// </summary>
        /// <param name="args"></param>
        public void OnNext(ExternalDataEventArgs args)
        {
            if (Next != null)
            {
                Next(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the Rehydrated event.
        /// </summary>
        /// <param name="args"></param>
        public void OnRehydrated(ExternalDataEventArgs args)
        {
            if (Rehydrated != null)
            {
                Rehydrated(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the IncomingSynchronize event.
        /// </summary>
        /// <param name="args"></param>
        public void OnIncomingSynchronize(IncomingSynchronizeEventArgs args)
        {
            if (IncomingSynchronize != null)
            {
                IncomingSynchronize(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the Error event.
        /// </summary>
        /// <param name="args"></param>
        public void OnError(ErrorEventArgs args)
        {
            if (Error != null)
            {
                Error(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the SkipToBasics event.
        /// </summary>
        /// <param name="args"></param>
        public void OnSkipToBasics(ExternalDataEventArgs args)
        {
            if (SkipToBasics != null)
            {
                SkipToBasics(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the SkipToAppearance event.
        /// </summary>
        /// <param name="args"></param>
        public void OnSkipToAppearance(ExternalDataEventArgs args)
        {
            if (SkipToAppearance != null)
            {
                SkipToAppearance(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the SkipToLifestyle event.
        /// </summary>
        /// <param name="args"></param>
        public void OnSkipToLifestyle(ExternalDataEventArgs args)
        {
            if (SkipToLifestyle != null)
            {
                SkipToLifestyle(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the SkipToInterests event.
        /// </summary>
        /// <param name="args"></param>
        public void OnSkipToInterests(ExternalDataEventArgs args)
        {
            if (SkipToInterests != null)
            {
                SkipToInterests(null, args);
            }
        }

        /// <summary>
        /// Wrapper for the host app to call the SkipToComplete event.
        /// </summary>
        /// <param name="args"></param>
        public void OnSkipToComplete(ExternalDataEventArgs args)
        {
            if (SkipToComplete != null)
            {
                SkipToComplete(null, args);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Turing Inc.
United States United States

Comments and Discussions