Singleton

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AppCode.Pattern
{
    public sealed class Singleton<T> 
        where T : class, new()
    {
        private static volatile T instance;
        private static object syncRoot = new Object();

        private Singleton() { }

        /// <summary>
        /// Returns an instance of the requested object
        /// </summary>
        public static T GetInstance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new T();
                        }
                    }
                }

                return instance;
            }
        }
    }
}