PostSharpAPI ReferencePost­Sharp.​Patterns.​ThreadingFreezable­Attribute
Open sandboxFocus

FreezableAttribute Class

Custom attribute that, when applied to a class, implements the FreezableThreadingModel to this class. The aspect introduces the IFreezable interface into the target class. After the Freeze() method has been invoked, the object can no longer be modified, and can therefore be safely shared between several threads.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading.dll
Syntax
[IntroduceInterface]
[Metric("UsedFeatures", "PostSharp.Patterns.Threading.Freezable")]
[Serializer]
public sealed class FreezableAttribute : ReadOnlyThreadAwareAttribute, ITypeLevelAspect, ITypeLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, ICloneAwareAspect, IInstanceScopedAspect, IAspectProvider, IService, IAdviceProvider, IAspect, IThreadAwareImplementationProvider, IQueryInterface, IConcurrencyController, IFreezable, IThreadAware
Remarks

Accessing a freezable object from a different thread than the one that created before the Freeze() method has been invoked it will result in a ThreadMismatchException.

Attempts to modify a freezable object after the Freeze() method has been invoked will result in an ObjectReadOnlyException.

Constructors

Name Description
FreezableAttribute()
FreezableAttribute(PortableFormatterConstructorContext)

Methods

Name Description
Advise(Object)

Injects the advice into the child object.

OnCloned(ICloneAwareAspect)

Method called after the an object enhanced by the current aspect has been cloned using System.Object.MemberwiseClone(). The this parameter refers to the new aspect instance in the cloned object.

ToString()

Explicit Interface Implementations

Name Description
IFreezable.Freeze()

Prevents the current object to be modified.

IThreadAware.ConcurrencyController

Gets the concurrency controller for the current object.