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

Attribute-flavored Domain Driven Design

Rate me:
Please Sign up or sign in to vote.
4.00/5 (2 votes)
6 Apr 2008CPOL8 min read 39.1K   231   25  
A centralized business domain with a common base
using System;
using System.Xml.Serialization;
using Codebasement.DomainDrivenDesign.Basement.Basement;
using Codebasement.DomainDrivenDesign.Basement.EventArguments;

namespace Codebasement.DomainDrivenDesign.Basement.Basement
{
    /// <summary>
    /// Summary description for Parameter.
    /// </summary>
    [Serializable]
    public class Parameter
    {
        [NonSerialized] private BasementObject _basementObject;
        [NonSerialized] private bool _isDirty;

        private string _name = String.Empty;
        private string _value = String.Empty;

        /// <summary>
        /// Initializes a new instance of the <see cref="Parameter"/> class.
        /// </summary>
        public Parameter()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Parameter"/> class.
        /// </summary>
        /// <param name="basementObject">The basement object.</param>
        /// <param name="name">The name.</param>
        public Parameter(BasementObject basementObject, string name) : this()
        {
            _basementObject = basementObject;
            _name = name;
        }

        /// <summary>
        /// Gets or sets the name
        /// </summary>
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        /// <summary>
        /// IsUpdated
        /// </summary>
        [XmlIgnore]
        public bool IsDirty
        {
            get { return _isDirty; }
            set { _isDirty = value; }
        }

        /// <summary>
        /// Gets or sets the content.
        /// </summary>
        /// <value>The content.</value>
        public string Value
        {
            get { return _value; }
            set
            {
                string oldValue = _value;
                string newValue = String.Empty;

                if (value != null)
                {
                    newValue = value;
                }

                // assign value if different
                if (oldValue != newValue)
                {
                    _value = newValue;

                    // mark property as changed
                    _isDirty = true;

                    // raise change event on BasementObject
                    if (_basementObject != null)
                        _basementObject.OnBasementObjectUpdated(new BasementObjectEventArgs(_basementObject));
                }
            }
        }
    }
}

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)
Netherlands Netherlands
Software engineer & architect.

Comments and Discussions