Generic Singelton pattern in C# and VB.NET

//SINGLETON - C#

using NUnit.Framework;

[TestFixture()]
public class SingletonTest
{
    [Test()]
    public void ObjectsAreTheSameTest()
    {
        DeploymentInfo firstDeployment = Singleton<DeploymentInfo>.UniqueInstance;
        DeploymentInfo secondDeployment = Singleton<DeploymentInfo>.UniqueInstance;
        Assert.AreSame(firstDeployment, secondDeployment);
    }
}

//Singleton Pattern 
//Generic Version

public class Singleton<T> where T : class, new()
{
    private Singleton()
    {
    }

    private class SingletonCreator
    {
        static SingletonCreator()
        {
        }
        // Private object instantiated with private constructor
        static internal readonly T instance = new T();
    }

    public static T UniqueInstance {
        get { return SingletonCreator.instance; }
    }
}


'SINGLETON - VB.NET

Imports NUnit.Framework

<TestFixture()> _
Public Class SingletonTest
    <Test()> _
    Public Sub ObjectsAreTheSameTest()
        Dim firstDeployment As DeploymentInfo = Singleton(Of DeploymentInfo).UniqueInstance
        Dim secondDeployment As DeploymentInfo = Singleton(Of DeploymentInfo).UniqueInstance
        Assert.AreSame(firstDeployment, secondDeployment)
    End Sub
End Class

'Singleton Pattern 
'Generic Version

Public Class Singleton(Of T As {Class, New})
    Private Sub New()
    End Sub

    Private Class SingletonCreator
        Shared Sub New()
        End Sub
        ' Private object instantiated with private constructor
        Friend Shared ReadOnly instance As New T()
    End Class

    Public Shared ReadOnly Property UniqueInstance() As T
        Get
            Return SingletonCreator.instance
        End Get
    End Property
End Class

NHiberanate datasource for ASP.NET

NHibernateDataSource: A DataSourceControl for ASP.NET 2.0

http://www.codeproject.com/KB/aspnet/NHibernateDataSource.aspx

Playing with Regex

Example - URL Extractor
http://www.dotnetcoders.com/web/Learning/Regex/exHrefExtractor.aspx

http://regexlib.com

http://sexyregex.com/regex/test/replace/3863#testdata

LINQ to SQL, WCF, REST and AJAX alternatives

Rick Strahl posted his session slides and samples from his ASP.NET Connections. Really good presentations.
http://west-wind.com/weblog/posts/336745.aspx

LINQ helper tools

LINQPad lets you interactively query SQL databases in a modern query language: LINQ.  Kiss goodbye to SQL Management Studio!
http://www.linqpad.net/

Visual LINQ Query Builder
http://code.msdn.microsoft.com/vlinq/