Click here to Skip to main content
15,892,005 members
Articles / Programming Languages / C#

Dynamic Decorator Pattern

Rate me:
Please Sign up or sign in to vote.
4.81/5 (13 votes)
30 Sep 2010CPOL3 min read 66.7K   909   53  
Extend functionality of an object without modifying its class or writing decoration code during design time
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace ThirdPartyHR
{
    public class Employee : IEmployee
    {
        #region Properties

        public System.Int32? EmployeeID { get; set; }
        public System.String FirstName { get; set; }
        public System.String LastName { get; set; }
        public System.DateTime DateOfBirth { get; set; }

        #endregion

        public Employee(
            System.Int32? employeeid
            , System.String firstname
            , System.String lastname
            , System.DateTime bDay
        )
        {
            this.EmployeeID = employeeid;
            this.FirstName = firstname;
            this.LastName = lastname;
            this.DateOfBirth = bDay;
        }

        public Employee() { }

        public System.String FullName()
        {
            System.String s = FirstName + " " + LastName;
            Console.WriteLine("Full Name: " + s);
            return s;
        }

        public System.Single Salary()
        {
            System.Single i = 10000.12f;
            Console.WriteLine("Salary: " + i);
            return i;
        }
    }
}

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
United States United States
Object-oriented (OO) is about "classes" not "objects". But I truly believe that "objects" deserve more our attentions. If you agree, read more on... Dynamic Object Programming (DOP), Component-Based Object Extender (CBO Extender), AOP Container and Dynamic Decorator Pattern.

Mobile development is not just another type of front end. The real challenge is actually in the back end: How to present meaningful information in time to mobile users with exponentially increased data flooding around? Here is my first mobile solution: SmartBars - Barcode Reader, Price Comparison and Coupons.

Gary lives in southeast Michigan. My first programming language is FORTRAN. For the last a few years, I have primarily focused on .NET technologies with Mobile Development as my newest interest.

Comments and Discussions