CSharpTest.Net
Factory Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > Singleton<T> Class : Factory Property

Glossary Item Box

Returns a factory that returns the singleton instance

Syntax

Visual Basic (Declaration) 
Public Shared ReadOnly Property Factory As IFactory(Of T)
C# 
public static IFactory<T> Factory {get;}

Example

Library/Library.Test/TestFactories.cs

C#Copy Code
try
{
    GC.KeepAlive(Singleton<BadObject>.Instance);
    Assert.Fail();
}
catch(ApplicationException ae)
{
    Assert.AreEqual("BadObject", ae.GetBaseException().Message);
}
try
{
    Singleton<BadObject>.Factory.Create();
    Assert.Fail();
}
catch (ApplicationException ae)
{
    Assert.AreEqual("BadObject", ae.GetBaseException().Message);
}
VB.NETCopy Code
Try
    GC.KeepAlive(Singleton(Of BadObject).Instance)
    Assert.Fail()
Catch ae As ApplicationException
    Assert.AreEqual("BadObject", ae.GetBaseException().Message)
End Try
Try
    Singleton(Of BadObject).Factory.Create()
    Assert.Fail()
Catch ae As ApplicationException
    Assert.AreEqual("BadObject", ae.GetBaseException().Message)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys