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

Refactoring Copy/Paste Pattern with Data-Structures

Rate me:
Please Sign up or sign in to vote.
4.50/5 (6 votes)
20 Jan 2011CPOL4 min read 25.1K   112   13  
Using data-structures to do away with boiler plate code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace SimpleDB
{
    public class ParameterDefinition
    {
        public ParameterDefinition(string name, SqlDbType dbType, ParameterDirection direction)
        {
            this.Name = name;
            this.DbType = dbType;
            this.Direction = direction;
        }

        public ParameterDefinition(string name, SqlDbType dbType, ParameterDirection direction, int size)
            : this(name, dbType, direction)
        {
            this.Size = size;
        }

        public ParameterDefinition(string name, SqlDbType dbType, ParameterDirection direction, object value)
            : this(name, dbType, direction)
        {
            this.Value = value;
        }

        public ParameterDefinition(string name, SqlDbType dbType, ParameterDirection direction, int size, object value)
            : this(name, dbType, direction, size)
        {
            this.Value = value;
        }

        public string Name
        {
            get;
            set;
        }

        public SqlDbType DbType
        {
            get;
            set;
        }

        public int? Size
        {
            get;
            set;
        }

        public ParameterDirection Direction
        {
            get;
            set;
        }

        public object Value
        {
            get;
            set;
        }
    }
}

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)
Portugal Portugal
Software Dev Gun For Hire.

Comments and Discussions