Click here to Skip to main content
12,510,189 members (49,570 online)
Click here to Skip to main content

Tagged as

Stats

17.9K views
304 downloads
32 bookmarked
Posted

Building an MVP Framework for .NET. Part 4: Strongly Typed Associations

, 25 Apr 2008 Ms-PL
In this article we continue developing a Model-View-Presenter framework for .NET platform. The new features we are implementing here are strongly typed asscoiations between controllers, views and tasks for higher convenience and type safety.
MVCSharp
API Docs
CleanUpAll.proj
Examples
ASP.NET MVC Store
ApplicationLogic
Model
NorthwindDataSet.xsc
NorthwindDataSet.xss
Presentation
App_Data
Nwind.mdb
Global.asax
Properties
Tests
Properties
TestApplicationLogic
Tests.csproj.user
Basics
Basics (generics used)
ApplicationLogic
Model
Presentation
Web
Global.asax
Win
Properties
ApplicationLogic
Model
Presentation
Web
Global.asax
Win
Properties
SimpleFormsViewsManager
Properties
TestSimpleFormsViewsManager
ApplicationLogic
Presentation
Properties
TasksInteraction
ApplicationLogic
Model
Presentation
Web
Global.asax
Win
Properties
WindowsFormsExample
ApplicationLogic
Presentation
Properties
MVCSharp
MVCSharp.Tests
Core
Configuration
Tasks
Views
Tasks
MVCSharp.Tests.csproj.user
Properties
Webforms
Configuration
Winforms
Configuration
Core
Configuration
Tasks
Views
Tasks
Views
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 to describe a task structure with XML string.
    /// Should be used with <see cref="MVCConfiguration.TaskInfoProviderType"/>
    /// property pointing to <see cref="TaskInfoByXmlAttributeProvider"/> or
    /// <see cref="DefaultTaskInfoProvider"/> types.
    /// </summary>
    /// <example>
    /// This is how a task structure is described with XML string inside the
    /// [Task] attribute:
    /// <code>
    /// [Task(@&quot;
    ///     &lt;interactionPoints&gt;
    ///         &lt;interactionPoint view = &quot;&quot;View1&quot;&quot; controllerType = &quot;&quot;MyApp.MyController1&quot;&quot;&gt;
    ///             &lt;navTarget trigger = &quot;&quot;To View2&quot;&quot; view = &quot;&quot;View2&quot;&quot;/&gt;
    ///             &lt;navTarget view = &quot;&quot;View3&quot;&quot;/&gt;
    ///         &lt;/interactionPoint&gt;
    ///         &lt;iPoint view = &quot;&quot;View2&quot;&quot; controllerType = &quot;&quot;MyApp.MyController2&quot;&quot;&gt;
    ///         &lt;/iPoint&gt;
    ///         &lt;interactionPoint view = &quot;&quot;View3&quot;&quot; controllerType = &quot;&quot;MyApp.MyController3&quot;&quot;&gt;
    ///             &lt;navTarget trigger = &quot;&quot;To View2&quot;&quot; view = &quot;&quot;View2&quot;&quot;/&gt;
    ///         &lt;/interactionPoint&gt;
    ///     &lt;/interactionPoints&gt;
    /// &quot;)]
    /// class MyTask1 { }
    /// </code>
    /// Note that it is possible to use either interactionPoint tag or its short
    /// analog iPoint. Next example shows how to define adjacent interaction points
    /// with transitions possible between each two of them.
    /// <code>
    /// [Task(@&quot;
    ///     &lt;interactionPoints&gt;
    ///         &lt;interactionPoint view = &quot;&quot;View1&quot;&quot; controllerType = &quot;&quot;MyApp.MyController1&quot;&quot;&gt;
    ///             &lt;navTarget trigger = &quot;&quot;View2&quot;&quot; view = &quot;&quot;View3&quot;&quot;/&gt;
    ///         &lt;/interactionPoint&gt;
    ///         &lt;iPoint view = &quot;&quot;View2&quot;&quot; controllerType = &quot;&quot;MyApp.MyController2&quot;&quot;/&gt;
    ///         &lt;iPoint view = &quot;&quot;View3&quot;&quot; controllerType = &quot;&quot;MyApp.MyController3&quot;&quot;/&gt;
    ///         &lt;interactionPoint view = &quot;&quot;View4&quot;&quot; controllerType = &quot;&quot;MyApp.MyController3&quot;&quot;/&gt;
    ///     &lt;/interactionPoints&gt;
    ///     &lt;adjacentPoints&gt;
    ///         &lt;iPointRef view = &quot;&quot;View1&quot;&quot;/&gt;
    ///         &lt;interactionPointRef view = &quot;&quot;View2&quot;&quot;/&gt;
    ///         &lt;iPointRef view = &quot;&quot;View3&quot;&quot;/&gt;
    ///     &lt;/adjacentPoints&gt;
    ///     &lt;adjacentPoints&gt;
    ///         &lt;iPointRef view = &quot;&quot;View2&quot;&quot;/&gt;
    ///         &lt;interactionPointRef view = &quot;&quot;View3&quot;&quot;/&gt;
    ///     &lt;/adjacentPoints&gt;
    ///     &lt;adjacentPoints&gt;
    ///         &lt;iPointRef view = &quot;&quot;View3&quot;&quot;/&gt;
    ///         &lt;iPointRef view = &quot;&quot;View4&quot;&quot;/&gt;
    ///     &lt;/adjacentPoints&gt;
    /// &quot;)]
    /// class MyTask2 { }
    /// </code>
    /// </example>
    #endregion
    [AttributeUsage(AttributeTargets.Class)]
    public class TaskAttribute : Attribute
    {
        private string xml;

        #region Documentation
        /// <summary>
        /// Xml string describing the task.
        /// </summary>
        #endregion
        public string Xml
        {
            get { return xml; }
        }

        #region Documentation
        /// <summary>
        /// Constructor taking the task XML description as a parameter.
        /// </summary>
        #endregion
        public TaskAttribute(string xml)
        {
            this.xml = xml;
        }
    }
}

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 Microsoft Public License (Ms-PL)

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...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160929.1 | Last Updated 25 Apr 2008
Article Copyright 2008 by Oleg Zhukov
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid