Click here to Skip to main content
15,881,248 members
Articles / Programming Languages / XML

netTierGenerator

Rate me:
Please Sign up or sign in to vote.
4.81/5 (20 votes)
30 Nov 2008CPOL14 min read 67.3K   2.8K   108  
A 3-tier application framework and code generation tool - the way for rapid and effective development.
using System;
using Sample.Common.Data;
using Sample.Common.Exception;
using Sample.Common.History;
using Sample.Common.Util;
using Sample.Common.Validation;

namespace Sample.Model.Store
{
	[Serializable]
	public partial class GoodInfoModel : BusinessEntity, ICloneable, IEquatable<GoodInfoModel>
	{
		#region Static Members
		private static readonly ValidationRules VALIDATION_RULES;
		#endregion Static Members

		#region members

		private string _name;
		private decimal _cost;
		private int _quantity;

		#endregion members

		#region properties

		[HistoryAttribute()]
		public string Name
		{
			[global::System.Diagnostics.DebuggerStepThrough]
			get { return this._name; }
			[global::System.Diagnostics.DebuggerStepThrough]
			set { this._name = value; }
		}
		[HistoryAttribute()]
		public decimal Cost
		{
			[global::System.Diagnostics.DebuggerStepThrough]
			get { return this._cost; }
			[global::System.Diagnostics.DebuggerStepThrough]
			set { this._cost = value; }
		}
		[HistoryAttribute()]
		public int Quantity
		{
			[global::System.Diagnostics.DebuggerStepThrough]
			get { return this._quantity; }
			[global::System.Diagnostics.DebuggerStepThrough]
			set { this._quantity = value; }
		}

		#endregion properties

		#region Constructors
		public GoodInfoModel(Guid _id, string _name, decimal _cost, int _quantity)
			: this()
		{
			this._id = _id;
			this._name = _name;
			this._cost = _cost;
			this._quantity = _quantity;
		}
		static GoodInfoModel()
		{
			GoodInfoModel.VALIDATION_RULES = new ValidationRules();
			GoodInfoModel.AddDatabaseSchemaRules();
			GoodInfoModel.AddCustomRules();
		}
		#endregion Constructors

		#region Public Methods
		public void Validate()
		{
			ValidationResult validationResult = GoodInfoModel.VALIDATION_RULES.Validate(this);

			if (!validationResult.IsValid)
			{
				throw new ValidationException(this, validationResult);
			}
		}
		#endregion Public Methods

		#region Static Methods
		private static void AddDatabaseSchemaRules()
		{
			GoodInfoModel.VALIDATION_RULES.AddRule(CommonRules.NotNull, "Name");
			GoodInfoModel.VALIDATION_RULES.AddRule(CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs("Name", 50));
			GoodInfoModel.VALIDATION_RULES.AddRule(CommonRules.NotNull, "Cost");
			GoodInfoModel.VALIDATION_RULES.AddRule(CommonRules.NotNull, "Quantity");
		}
		#endregion Static Methods

		#region ICloneable Members
		public object Clone()
		{
			GoodInfoModel clone = new GoodInfoModel();
			clone.Id = this.Id;
			clone.Name = this.Name;
			clone.Cost = this.Cost;
			clone.Quantity = this.Quantity;
			return clone;
		}
		#endregion ICloneable Members

		#region IEquatable<GoodInfoModel> Members
		public bool Equals(GoodInfoModel other)
		{
			if (other == null) { return false; }
			if (Object.ReferenceEquals(this, other)) { return true; }

			return
				this.Id == other.Id &&
				this.Name == other.Name &&
				this.Cost == other.Cost &&
				this.Quantity == other.Quantity;
		}
		#endregion IEquatable<GoodInfoModel> Members
	}
}

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)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions