Click here to Skip to main content
15,893,486 members
Articles / Web Development / HTML

Leveraging .NET Components and IDE Integration: UI AOP in an MVC use case

Rate me:
Please Sign up or sign in to vote.
4.99/5 (125 votes)
28 Jun 200598 min read 354.2K   835   384  
An in-depth exploration of the features and the power of .NET Component Model architecture, its integration with the IDE at design-time and the possiblities it opens through extensions at run-time.
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Reflection;
using System.Web.UI.Design;

using Mvc.Components.Design;

namespace Mvc.Components.Controller
{
	/// <summary>
	/// This class represents a link between the view and the model.
	/// </summary>
	[TypeConverter(typeof(ExpandableObjectConverter))]
	public class ViewInfo
	{
		#region Internal members, overrides & ctors
		/// <summary>
		/// Provides a means to link this view information with the parent controller.
		/// </summary>
		internal BaseController Controller;

		/// <summary>
		/// Provides a friendly string representation.
		/// </summary>
		public override string ToString()
		{
			if (_controlproperty == String.Empty && 
				_model == String.Empty && _modelproperty == String.Empty)
				return "No mapping configured.";
			else
				return _model + "." + _modelproperty + " -> " + _controlid + "." + _controlproperty;
		}

		public ViewInfo()
		{
		}

		public ViewInfo(BaseController parentController, string controlId)
		{
			Controller = parentController;
			_controlid = controlId;
		}

		public ViewInfo(string controlId, string controlProperty, string model, string modelProperty)
		{
			_controlid = controlId;
			_controlproperty = controlProperty;
			_model = model;
			_modelproperty = modelProperty;
		}

		/// <summary>
		/// The control ID.
		/// </summary>
		internal string ControlID
		{
			get { return _controlid; }
			set { _controlid = value; }
		} string _controlid = String.Empty;

		/// <summary>
		/// Indicates whether the class has already been hooked to property change handlers.
		/// </summary>
		internal bool IsHooked
		{
			get { return _ishooked; }
			set { _ishooked = value; }
		} bool _ishooked = false;

		#endregion

		#region Public properties

		/// <summary>
		/// The name of the model in use.
		/// </summary>
		[TypeConverter(typeof(ModelNameConverter))]
		public string Model
		{
			get { return _model; }
			set { _model = value; }
		} string _model = String.Empty;
		
		/// <summary>
		/// The model property used by this mapping.
		/// </summary>
		[DefaultValue("")]
		[TypeConverter(typeof(ModelPropertyConverter))]
		public string ModelProperty
		{
			get { return _modelproperty; }
			set { _modelproperty = value; }
		} string _modelproperty = String.Empty;

		/// <summary>
		/// The control property updated by this mapping.
		/// </summary>
		[DefaultValue("")]
		[TypeConverter(typeof(ControlPropertyConverter))]
		public string ControlProperty
		{
			get { return _controlproperty; }
			set { _controlproperty = value; }
		} string _controlproperty = String.Empty;

		#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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Argentina Argentina

Comments and Discussions