November 3, 2008
@ 12:04 AM
Birçoğuz biliyoruz ki, kimi zaman belirli bir classdan çalışma zamanında sadece tek bir nesne oluşturulmasını isteriz. Aynı sınıfa ait ikinci bir nesne oluşmasını engellemek isteriz. Bu durumda Singleton Tasarım Kalıbını (Alper Hoca'nın kulakları çınlasın)  uygularız. Fakat birçok class için bu durum geçerli ise her defasında bunu uygulamak bizim gibi üşengeç programcılar için can sıkıcı hal alır. Çözüm ise,
    
class GenericSingleton<T> where T : class, new()
{
    private static object lockObject = new object();
    private static T m_Instance;

    public static T GetInstance()
    {
        if( m_Instance != null)
            return m_Instance;
        lock ( lockObject)
        {
            if (m_Instance == null)
            {
                m_Instance = new T();
            }            
        }
        return m_Instance;
    }
}

Bu generics süper bişi! - ben bu lafı bir yerden hatırlıyorum ama -


 
Tuesday, December 22, 2009 3:21:42 AM (GTB Standard Time, UTC+02:00)
20091222c1ygy I wear <a href="http://www.boonoutlet.com/ugg-genuine-womens-nightfall-boots-black-p-1251.html">UGG Nightfall Boots on sale</a>is considered a kind of a fashion trend, this trend has affected the whole world. If you have not tried, then it is regrettable. With the advent of winter, <a href="http://www.boonoutlet.com/ugg-new-arrival-suede-boots-5230-black-p-1279.html">UGG New Arrival Suede Boots </a>online become popular up a lot of people can not wait to experience the feeling of wearing ugg prices ugg some people appear to be high, ugg boots online above ugg style good, <a href="http://www.boonoutlet.com/ugg-boots-gray-carved-in-pattern-on-hot-sale-p-1226.html">UGG Gray classic tall</a> are always welcome to many people as it is high quality and fashion design.For myself,i like this
<a href="http://www.boonoutlet.com/ugg-authority-classic-mini-boot-black-for-women-p-1014.html">UGG Classic Mini Boot </a> very much,you can have it and show yourself now,it is not let you downUgg Napoule Sandal,the price is not expensive. To meet your needs, make haste to experience the feeling of the trend.


Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview