Open sandboxFocus

Class FreezableAttribute

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(typeof(IFreezable), OverrideAction = InterfaceOverrideAction.Ignore, LinesOfCodeAvoided = 5)]
[Metric("UsedFeatures", "PostSharp.Patterns.Threading.Freezable")]
[Serializer(typeof(FreezableAttribute.Serializer))]
public sealed class FreezableAttribute : ReadOnlyThreadAwareAttribute, ITypeLevelAspect, ITypeLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, ICloneAwareAspect, IInstanceScopedAspect, IAspectProvider, IService, IAdviceProvider, IAspect, 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 MemberwiseClone(). The this parameter refers to the new aspect instance in the cloned object.

ToString()