Click here to Skip to main content
15,891,136 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.2K   231   25  
A centralized business domain with a common base
using System;
using Codebasement.DomainDrivenDesign.Basement.Enums;

namespace Codebasement.DomainDrivenDesign.Basement.Attributes
{
    /// <summary>
    /// RelatableAttribute
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
    public sealed class RelatableAttribute : Attribute
    {
        private Type _basementObjectType;
        private int _cardinality;
        private CardinalityType _cardinalityType;

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

        /// <summary>
        /// Initializes a new instance of the <see cref="RelatableAttribute"/> class.
        /// </summary>
        /// <param name="basementObjectType">Type of the basement object.</param>
        /// <param name="cardinality">The cardinality.</param>
        /// <param name="cardinalityType">Type of the cardinality.</param>
        public RelatableAttribute(Type basementObjectType, int cardinality, CardinalityType cardinalityType)
        {
            _basementObjectType = basementObjectType;
            _cardinality = cardinality;
            _cardinalityType = cardinalityType;
        }

        /// <summary>
        /// Gets or sets the type of the basement object.
        /// </summary>
        /// <value>The type of the basement object.</value>
        public Type BasementObjectType
        {
            get { return _basementObjectType; }
            set { _basementObjectType = value; }
        }

        /// <summary>
        /// Gets or sets the cardinality.
        /// </summary>
        /// <value>The cardinality.</value>
        public int Cardinality
        {
            get { return _cardinality; }
            set { _cardinality = value; }
        }

        /// <summary>
        /// Gets or sets the type of the cardinality.
        /// </summary>
        /// <value>The type of the cardinality.</value>
        public CardinalityType CardinalityType
        {
            get { return _cardinalityType; }
            set { _cardinalityType = value; }
        }
    }
}

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