Open sandboxFocus

Class RecordableAttribute

Custom attribute that, when applied to a class, instruments fields and methods of this class so that it can be involved in undo/redo operations.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model.dll
Syntax
[IntroduceInterface(typeof(IRecordable), OverrideAction = InterfaceOverrideAction.Ignore, AncestorOverrideAction = InterfaceOverrideAction.Ignore)]
[IntroduceInterface(typeof(IQueryInterface), OverrideAction = InterfaceOverrideAction.Ignore, AncestorOverrideAction = InterfaceOverrideAction.Ignore)]
[MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict, AllowMultiple = false, TargetTypeAttributes = MulticastAttributes.UserGenerated)]
[Metric("UsedFeatures", "PostSharp.Patterns.Recording.Recordable")]
[ProvideAspectRole("ChangeTracking")]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, "Tracing")]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, "Threading")]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, "Validation")]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, "Caching")]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, "CacheInvalidation")]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, "ThreadingModel")]
[AspectTypeDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, typeof(AggregatableAttribute))]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.Before, "DataBinding")]
[AspectRoleDependency(AspectDependencyAction.Commute, "EditableObjectImplementation")]
[AspectTypeDependency(AspectDependencyAction.Conflict, typeof(RecordableAttribute))]
[Obsolete("[Recordable] aspect and its components are deprecated and will be removed in a future version.", false)]
[Serializer(typeof(RecordableAttribute.Serializer))]
public sealed class RecordableAttribute : InstanceLevelAspect, ITypeLevelAspect, ITypeLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, ICloneAwareAspect, IInstanceScopedAspect, IRecordable, IAspectProvider, IAspect, IService, IQueryInterface, IDynamicInterfaceImplementation
Remarks

The aspect records each change to a field of the target object as an Operation in the Recorder to which the object is attached. By default, when the constructor completes, the aspect attaches the object to the recorder returned by RecorderProvider, which is DefaultRecorder unless you replace the provider. To attach objects manually with Attach(object), set the AutoRecord property to false.

The aspect wraps each public or internal instance method, except property getters and event accessors, in an implicit RecordingScope, so that a call from outside the object model becomes a single logical operation. Use RecordingScopeAttribute to name or skip these scopes, and NotRecordedAttribute to exclude a field or property from recording.

The aspect relies on the AggregatableAttribute aspect, which it adds to the target class if needed.

Constructors

Name Description
RecordableAttribute()

Initializes a new instance of the RecordableAttribute class.

RecordableAttribute(PortableFormatterConstructorContext)

Properties

Name Description
AutoRecord

Gets or sets a value indicating whether changes in this object must be recorded as soon as the object constructor has completed.

ProvideMethodContext

Gets or sets a value indicating whether the full method invocation context is provided to the MethodExecutionOperationDescriptor class for use in a custom OperationFormatter. By default, this property is false for performance reasons.

Methods

Name Description
CompileTimeInitialize(Type, AspectInfo)

Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

CompileTimeValidate(Type)

Method invoked at build time to ensure that the aspect has been applied to the right target.

See Also