Click here to Skip to main content
11,640,866 members (61,244 online)
Click here to Skip to main content
Add your own
alternative version

Navigational Workflows Unleashed in WWF/ASP.NET 3.5

, 21 Oct 2008 CPOL 151.6K 1.5K 166
Case-study on the internals of a Navigational Workflow engine for a fictional dating website called “World Wide Dating”.
datesite.zip
DateSite
App_Data
bin
database setup procedure
DateSite.csproj.user
Global.asax
images
complete.png
critical.png
logo2.png
warning.png
Profile.dbml
Profile.dbml.layout
Properties
Service References
NavigationWorkflow
bin
NavigationWorkflow.layout
Properties
Settings.settings
using System;
using System.Configuration;

namespace DateSiteNavigation
{

    #region Navigation Section 

    /// <summary>
    /// Class representing a config section in the web.config.
    /// </summary>
    public class NavigationSection : ConfigurationSection
    {
        private static NavigationSection _current;

        /// <summary>
        /// Gets a static reference to the navigation section object in the web.config.
        /// </summary>
        public static NavigationSection Current
        {
            get
            {
                if (_current == null)
                {
                    _current = ConfigurationManager.GetSection("Navigation") as NavigationSection;
                }

                return _current;
            }
        }

        /// <summary>
        /// Gets or sets the navigation elements collection.
        /// </summary>
        [ConfigurationProperty("elements")]
        public NavigationElementCollection Elements
        {
            get { return base["elements"] as NavigationElementCollection; }
            set { base["elements"] = value; }
        }

        /// <summary>
        /// Gets or sets the error elements collection.
        /// </summary>
        [ConfigurationProperty("errors")]
        public ErrorElementCollection Errors
        {
            get { return base["errors"] as ErrorElementCollection; }
            set { base["errors"] = value; }
        }
    }

    #endregion

    #region  Navigation Elements

    /// <summary>
    /// Class representing a collection of navigation elements.
    /// </summary>
    [ConfigurationCollection(typeof(NavigationElement), AddItemName = "element", CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
    public class NavigationElementCollection : ConfigurationElementCollection
    {
        protected override System.Configuration.ConfigurationElement CreateNewElement()
        {
            return new NavigationElement();
        }

        protected override object GetElementKey(System.Configuration.ConfigurationElement element)
        {
            return (element as NavigationElement).StateName;
        }

        public NavigationElement this[int index]
        {
            get { return (NavigationElement)base.BaseGet(index); }
        }

        public NavigationElement this[string stateName]
        {
            get { return (NavigationElement)base.BaseGet(stateName); }
        }

        public NavigationElement GetElementByPageName(string pageName)
        {
            System.Collections.IEnumerator enumerator = this.GetEnumerator();

            while (enumerator.MoveNext())
            {
                NavigationElement current = enumerator.Current as NavigationElement;
                if (current.PageName.Equals(pageName))
                {
                    return current;
                }
            }

            return new NavigationElement();
        }
    }

    /// <summary>
    /// Class representing a navigation element.
    /// </summary>
    public class NavigationElement : ConfigurationElement
    {
        [ConfigurationProperty("stateName")]
        public string StateName
        {
            get { return Convert.ToString(base["stateName"]); }
            set { base["stateName"] = value; }
        }

        [ConfigurationProperty("pageName")]
        public string PageName
        {
            get { return Convert.ToString(base["pageName"]); }
            set { base["pageName"] = value; }
        }

        [ConfigurationProperty("weight")]
        public int Weight
        {
            get { return Convert.ToInt32(base["weight"]); }
            set { base["weight"] = value; }
        }
    }

    #endregion

    #region Error Elements

    /// <summary>
    /// Class representing a collection of error elements.
    /// </summary>
    [ConfigurationCollection(typeof(ErrorElement), AddItemName = "error", CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
    public class ErrorElementCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new ErrorElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return (element as ErrorElement).ErrorName;
        }

        public ErrorElement this[int index]
        {
            get { return (ErrorElement)base.BaseGet(index); }
        }

        public ErrorElement this[string stateName]
        {
            get { return (ErrorElement)base.BaseGet(stateName); }
        }
    }

    /// <summary>
    /// Class representing an error element.
    /// </summary>
    public class ErrorElement : ConfigurationElement
    {
        [ConfigurationProperty("errorName")]
        public string ErrorName
        {
            get { return Convert.ToString(base["errorName"]); }
            set { base["errorName"] = value; } 
        }

        [ConfigurationProperty("pageName")]
        public string PageName
        {
            get { return Convert.ToString(base["pageName"]); }
            set { base["pageName"] = value; }
        }
    }

    #endregion

}

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)

Share

About the Author

Pero Matić
Software Developer (Senior) Plan A Software
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150731.1 | Last Updated 21 Oct 2008
Article Copyright 2008 by Pero Matić
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid