Click here to Skip to main content
15,885,115 members
Articles / Programming Languages / C#

Declarative Programming Of The MVC Pattern Within The Context Of DataBinding

Rate me:
Please Sign up or sign in to vote.
4.88/5 (14 votes)
31 May 200410 min read 87.9K   311   90  
Exploring the MVC pattern.
/*
 * Copyright (c) 2004 Marc Clifton
 * All Rights Reserved
 * 
 * License: GNU General Public License, see doc\license.txt
 * http://www.gnu.org/licenses/licenses.html#GPL
 * Owner: Marc Clifton email: webmaster@knowledgeautomation.com
 * First release published:
 * http://www.codeproject.com/cs/miscctrl/xmlGuiGenerator.asp
 * 2/25/04
*/

using System;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using System.Xml;

using MyXaml;

namespace MyXaml.Extensions
{
	public class MxDataRowModel : PropertyModelBase
	{
		public override object SetValue(object obj, PropertyInfo pi, object val)
		{
			DataTable dataTable=null;
			DataRow dr=null;
			try
			{
				if (parser.ObjectStack.Count >= 2)
				{
					dataTable=(DataTable)((ObjectInfo)parser.ObjectStack.ToArray()[1]).Instance;
					dr=dataTable.NewRow();
					foreach (XmlAttribute attribute in currentNode.Attributes)
					{
						try
						{
							dr[attribute.Name]=attribute.Value;
						}
						catch(Exception e)
						{
							Trace.WriteLine("DataRow setter failed: "+e.Message);
						}
					}
					dataTable.Rows.Add(dr);
				}
				AttributesProcessed=true;
			}
			catch(Exception e)
			{
				Trace.WriteLine("DataRow setter failed: "+e.Message);
			}

			return dr;
		}
	}

	// placeholer for the "DataRow" tag.
	public class DataRowModel : MxDataRowModel
	{
	}
}

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
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions