Click or drag to resize
DigitalRuneSingletonT Class
Base class for types to restrict instantiation to one object ("singleton pattern").
Inheritance Hierarchy
SystemObject
  DigitalRuneSingletonT
    More...

Namespace: DigitalRune
Assembly: DigitalRune (in DigitalRune.dll) Version: 1.20.0.0 (1.20.1.14552)
Syntax
public abstract class Singleton<T>
where T : new(), Singleton<T>

Type Parameters

T
The type of the object that is instantiated.

The SingletonT type exposes the following members.

Constructors
  NameDescription
Protected methodSingletonT
Initializes a new instance of the SingletonT class.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyStatic memberInstance
Gets the singleton of type T.
Top
Remarks

Important: In Silverlight the singleton type T needs to be a public type (not a private or internal). This is necessary because of security restrictions in Silverlight.

Thread-Safety: This class is thread-safe. The property Instance can be accessed by multiple threads simultaneously.

Examples
A class can derive from SingletonT like the class Log in this example:
public class Log : Singleton<Log>
{
  ...
}
The singleton can be instantiated/accessed by using the property Instance.
var log = Log.Instance;
var log = Singleton<Log>.Instance;
See Also
Inheritance Hierarchy
SystemObject
  DigitalRuneSingletonT
    DigitalRune.Animation.TraitsAvatarExpressionTraits
    DigitalRune.Animation.TraitsColorTraits
    DigitalRune.Animation.TraitsQuaternionFTraits
    DigitalRune.Animation.TraitsQuaternionTraits
    DigitalRune.Animation.TraitsSingleTraits
    DigitalRune.Animation.TraitsSkeletonPoseTraits
    DigitalRune.Animation.TraitsSrtTransformTraits
    DigitalRune.Animation.TraitsVector2FTraits
    DigitalRune.Animation.TraitsVector2Traits
    DigitalRune.Animation.TraitsVector3FTraits
    DigitalRune.Animation.TraitsVector3Traits
    DigitalRune.Animation.TraitsVector4FTraits
    DigitalRune.Animation.TraitsVector4Traits
    DigitalRune.Graphics.SceneGraphAscendingNodeComparer
    DigitalRune.Graphics.SceneGraphDescendingNodeComparer