NanoByte.Common
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
NanoByte.Common.Undo.SetValueCommand< T > Class Template Reference

An undo command that uses a delegates for getting and setting values from a backing model. More...

Inheritance diagram for NanoByte.Common.Undo.SetValueCommand< T >:
NanoByte.Common.Undo.SimpleCommand NanoByte.Common.Undo.IValueCommand NanoByte.Common.Undo.IUndoCommand NanoByte.Common.Undo.IUndoCommand

Public Member Functions

 SetValueCommand ([NotNull] PropertyPointer< T > pointer, T newValue)
 Creates a new value-setting command. More...
 
- Public Member Functions inherited from NanoByte.Common.Undo.SimpleCommand
void Execute ()
 Performs the desired action. More...
 
virtual void Undo ()
 Undoes the changes made by Execute. More...
 

Static Public Member Functions

static SetValueCommand< T > For< T > ([NotNull] PropertyPointer< T > pointer, T newValue)
 Creates a new value-setting command. More...
 
static SetValueCommand< T > For< T > ([NotNull] Func< T > getValue, [NotNull] Action< T > setValue, T newValue)
 Creates a new value-setting command. More...
 
static SetValueCommand< T > For< T > ([NotNull] Expression< Func< T >> expression, T newValue)
 Creates a new value-setting command. More...
 

Public Attributes

object Value => _newValue
 

Protected Member Functions

override void OnExecute ()
 Sets the new value in the model. More...
 
override void OnUndo ()
 Restores the old value in the model. More...
 

Additional Inherited Members

- Properties inherited from NanoByte.Common.Undo.IValueCommand
object Value [get]
 

Detailed Description

An undo command that uses a delegates for getting and setting values from a backing model.

Factory methods for SetValueCommand<T>.

Template Parameters
TThe type of the value to set.

Constructor & Destructor Documentation

◆ SetValueCommand()

NanoByte.Common.Undo.SetValueCommand< T >.SetValueCommand ( [NotNull] PropertyPointer< T >  pointer,
newValue 
)
inline

Creates a new value-setting command.

Parameters
pointerThe object controlling how to read/write the value to be modified.
newValueThe new value to be set.

Member Function Documentation

◆ For< T >() [1/3]

static SetValueCommand<T> NanoByte.Common.Undo.SetValueCommand< T >.For< T > ( [NotNull] PropertyPointer< T >  pointer,
newValue 
)
static

Creates a new value-setting command.

Parameters
pointerThe object controlling how to read/write the value to be modified.
newValueThe new value to be set.
Template Parameters
TThe type of the value to set.

◆ For< T >() [2/3]

static SetValueCommand<T> NanoByte.Common.Undo.SetValueCommand< T >.For< T > ( [NotNull] Func< T >  getValue,
[NotNull] Action< T >  setValue,
newValue 
)
static

Creates a new value-setting command.

Parameters
getValueA delegate that returns the current value.
setValueA delegate that sets the value.
newValueThe new value to be set.
Template Parameters
TThe type of the value to set.

◆ For< T >() [3/3]

static SetValueCommand<T> NanoByte.Common.Undo.SetValueCommand< T >.For< T > ( [NotNull] Expression< Func< T >>  expression,
newValue 
)
static

Creates a new value-setting command.

Template Parameters
TThe type of value the property contains.
Parameters
expressionAn expression pointing to the property.
newValueThe new value to be set.

◆ OnExecute()

override void NanoByte.Common.Undo.SetValueCommand< T >.OnExecute ( )
inlineprotectedvirtual

Sets the new value in the model.

Implements NanoByte.Common.Undo.SimpleCommand.

◆ OnUndo()

override void NanoByte.Common.Undo.SetValueCommand< T >.OnUndo ( )
protectedvirtual

Restores the old value in the model.

Implements NanoByte.Common.Undo.SimpleCommand.


The documentation for this class was generated from the following file: