Click here to Skip to main content
15,881,455 members
Articles / Programming Languages / SQL

Optimistic Concurrency with C# using the IOC and DI Design Patterns

Rate me:
Please Sign up or sign in to vote.
4.23/5 (6 votes)
25 Feb 2009CPOL2 min read 38.3K   223   32  
Discussion of concurrency using the IOC and DI Design Patterns with the PostgreSQL database.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WFrmAppIOC
{
    /// <summary>
    /// iDatabase - Abstract class for datbase providers. 
    /// </summary>
    public abstract class iDatabase
    {
        string strdbName;        // the database name
        string strServer;        // the database name
        string struserName;      // the user name
        string strpassword;      // the password 
        string strSAName;        // the SA user name
        string strSApassword;    // the SA password 
        /// <summary>
        /// iDatabase - constructor 
        /// </summary>
        public iDatabase()
        {
            strdbName = "";             // the database name
            strServer = "";             // the database name
            struserName = "";           // the user name
            strpassword = "";           // the password 
            strSAName = "";             // the SA user name
            strSApassword = "";         // the SA password 
        }
        /// <summary>
        /// DBName - get/set 
        /// </summary>
        public string DBName
        {
            get
            {
                return (strdbName);
            }
            set
            {
                strdbName = value;
            }
        }
        /// <summary>
        /// Server - get/set
        /// </summary>
        public string Server
        {
            get
            {
                return (strServer);
            }
            set
            {
                strServer = value;
            }
        }
        /// <summary>
        /// UserName - get/set
        /// </summary>
        public string UserName
        {
            get
            {
                return (struserName);
            }
            set
            {
                struserName = value;
            }
        }
        /// <summary>
        /// Password - get/set
        /// </summary>
        public string Password
        {
            get
            {
                return (strpassword);
            }
            set
            {
                strpassword = value;
            }
        }
        /// <summary>
        /// SAUserName - get/set
        /// </summary>
        public string SAUserName
        {
            get
            {
                return (strSAName);
            }
            set
            {
                strSAName = value;
            }
        }
        /// <summary>
        /// SAPassword - get/set
        /// </summary>
        public string SAPassword
        {
            get
            {
                return (strSApassword);
            }
            set
            {
                strSApassword = value;
            }
        }
        /// <summary>
        /// CheckDBConnectionInfo - cehk the db connection information
        /// </summary>
        public abstract void CheckDBConnectionInfo();
        /// <summary>
        /// GetUserPassword
        /// </summary>
        /// <param name="userName">User name</param>
        /// <returns>password</returns>
        public abstract string GetUserPassword(string userName);
        /// <summary>
        /// UpdateUser - update the user record.
        /// </summary>
        /// <param name="ud"></param>
        /// <returns></returns>
        public abstract int UpdateUser(UserData ud);
        /// <summary>
        /// AddUser - ass the user. 
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="Password"></param>
        /// <param name="ModUser"></param>
        /// <returns></returns>
        public abstract int AddUser(string userName, string Password, string ModUser);
        /// <summary>
        /// GetUser
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public abstract UserData GetUser(string userName);
    }
}

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
Web Developer
United States United States
I am a Director of Engineering, have an MBA and work in C# forms, Asp.Net and vb.net. I have been writing Windows program since windows 3.0. I am currently working in the Healthcare industry.

I enjoy reading, music (most types), and learning new technology. I am involved in opensource projects at codeplex.

My linkedin link is
http://www.linkedin.com/in/donsweitzer

Comments and Discussions