Click here to Skip to main content
11,702,396 members (72,648 online)
Click here to Skip to main content
Add your own
alternative version

Building an MVP Framework for .NET. Part 2: Implementing Core Functionality

, 11 Feb 2008 CPOL 63.8K 1.1K 87
Basing on the concepts introduced in the first part, this article proceeds to implement the core MVP Framework funtionality.
mvcsharp.zip
MVCSharp
API Docs
CleanUpAll.proj
Examples
Basics
ApplicationLogic
Model
Presentation
Web
Global.asax
Win
Properties
Settings.settings
SimpleFormsViewsManager
Properties
TestSimpleFormsViewsManager
ApplicationLogic
Presentation
Properties
Settings.settings
TasksInteraction
ApplicationLogic
Model
Presentation
Web
Global.asax
Win
Properties
Settings.settings
WindowsFormsExample
ApplicationLogic
Presentation
Properties
Settings.settings
MVCSharp
Core
Configuration
Tasks
Views
Tasks
Views
Properties
Webforms
Configuration
Winforms
Configuration
MVCSharp.Tests
Core
Configuration
Tasks
Views
Tasks
MVCSharp.Tests.csproj.user
Properties
Webforms
Configuration
Winforms
Configuration
//===========================================
// MVC# Framework | www.MVCSharp.org        |
// ------------------------------------------
// Copyright (C) 2008 www.MVCSharp.org      |
// All rights reserved.                     |
//===========================================

using System;
using System.Text;

namespace MVCSharp.Core.Configuration.Tasks
{
    #region Documentation
    /// <summary>
    /// Attribute for describing interaction points within a task.
    /// </summary>
    /// <remarks>Should be used with <see cref="TaskInfoByAttributesProvider"/> or
    /// <see cref="DefaultTaskInfoProvider"/> task info providers. They
    /// convert this attribute occurrences into <see cref="TaskInfo"/>
    /// objects.</remarks>
    /// <example>
    /// Here is an example of how this attribute may be used:
    /// <code>
    /// class MyTask
    /// {
    ///     [InteractionPoint(typeof(MyController1))]
    ///     public const string iPoint1 = "View1";
    /// 
    ///     [IPoint(typeof(MyController2), true, iPoint1)]
    ///     public const string iPoint2 = "View2";
    /// 
    ///     [InteractionPoint(typeof(MyController1), iPoint1, iPoint2)]
    ///     public const string iPoint3 = "View3";
    /// 
    ///     [InteractionPoint(typeof(MyController1), true)]
    ///     [NavTarget("Next", iPoint3)]
    ///     [NavTarget("Previous", iPoint2)]
    ///     public const string iPoint4 = "View4";
    /// }
    /// </code>
    /// </example>
    #endregion
    [AttributeUsage(AttributeTargets.Field)]
    public class InteractionPointAttribute : Attribute
    {
        private bool isCommonTarget;
        private Type controllerType;
        private string[] navTargets;

        #region Documentation
        /// <summary>
        /// Constructor taking the controller type and an array of
        /// navigation targets for this interation point.
        /// </summary>
        #endregion
        public InteractionPointAttribute(Type controllerType,
                                         params string[] navTargets)
                : this (controllerType, false, navTargets){ }

        #region Documentation
        /// <summary>
        /// Constructor taking the controller type and a parameter specifying
        /// whether the interaction point is a common target for other points.
        /// </summary>
        #endregion
        public InteractionPointAttribute(Type controllerType,
                                         bool isCommonTarget)
                : this(controllerType, isCommonTarget, new string[0]) { }

        #region Documentation
        /// <summary>
        /// Constructor taking the controller type, a parameter specifying
        /// whether the interaction point is a common target for other points
        /// and an array of navigation targets for this interation point.
        /// </summary>
        #endregion
        public InteractionPointAttribute(Type controllerType, bool isCommonTarget,
                                                        params string[] navTargets)
        {
            this.controllerType = controllerType;
            this.isCommonTarget = isCommonTarget;
            this.navTargets = navTargets;
        }

        #region Documentation
        /// <summary>
        /// Specifies the type of the controller for the interaction point.
        /// </summary>
        #endregion
        public Type ControllerType
        {
            get { return controllerType; }
            set { controllerType = value; }
        }

        #region Documentation
        /// <summary>
        /// Specifies whether the interaction point should be a common target
        /// (i.e. a navigation can be done from any other interaction point to this one).
        /// </summary>
        #endregion
        public bool IsCommonTarget
        {
            get { return isCommonTarget; }
            set { isCommonTarget = value; }
        }

        #region Documentation
        /// <summary>
        /// Gets or sets an array of target navigation points represented by
        /// their view names. Any of these interaction points can be navigated
        /// to with the trigger name equal to the target view name.
        /// </summary>
        #endregion
        public string[] NavTargets
        {
            get { return navTargets; }
            set { navTargets = value; }
        }
    }

    #region Documentation
    /// <summary>
    /// Equivalent to the <see cref="InteractionPointAttribute"/> attribute.
    /// </summary>
    #endregion
    [AttributeUsage(AttributeTargets.Field)]
    public class IPointAttribute : InteractionPointAttribute
    {
        #region Documentation
        /// <summary>
        /// See <see cref="InteractionPointAttribute"/> equivalent constructor.
        /// </summary>
        #endregion
        public IPointAttribute(Type controllerType, params string[] navTargets)
            : base(controllerType, navTargets)
        { }

        #region Documentation
        /// <summary>
        /// See <see cref="InteractionPointAttribute"/> equivalent constructor.
        /// </summary>
        #endregion
        public IPointAttribute(Type controllerType,
                               bool isCommonTarget)
            : base(controllerType, isCommonTarget) { }

        #region Documentation
        /// <summary>
        /// See <see cref="InteractionPointAttribute"/> equivalent constructor.
        /// </summary>
        #endregion
        public IPointAttribute(Type controllerType, bool isCommonTarget,
            params string[] navTargets) : base(controllerType, isCommonTarget, navTargets)
        { }
    }
}

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

Oleg Zhukov
Team Leader
Russian Federation Russian Federation
Oleg Zhukov, born and living in Russia is Lead Engineer and Project Manager in a company which provides business software solutions. He has graduated from Moscow Institute of Physics and Technology (MIPT) (department of system programming) and has got a M.S. degree in applied physics and mathematics. His research and development work concerns architectural patterns, domain-driven development and systems analysis. Being the adherent of agile methods he applies them extensively in the projects managed by him.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150819.1 | Last Updated 11 Feb 2008
Article Copyright 2008 by Oleg Zhukov
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid