Table of Contents

Class ReversibleChange

Namespace
CADability
Assembly
CADability.dll

This class contains the information to undo a change in the project database. Undoing a change is done by reflection. So we need an object, the name of a method or a property and the parameters to use in the call. This information must be provided in the constructor. The method or property must have public access.

public class ReversibleChange
Inheritance
ReversibleChange
Derived
Inherited Members

Constructors

ReversibleChange(Func<bool>)

The provided funtion knows how to undo the change and has the data, which is needed for the undo, captured

public ReversibleChange(Func<bool> undo)

Parameters

undo Func<bool>

ReversibleChange(object, string, GeoObjectList)

Creates a ReversibleChange with a single GeoObjectList parameter, e.g. to undo Remove(GeoObjectList) by calling Add(GeoObjectList).

This overload must exist: GeoObjectList defines an implicit conversion to IGeoObject[], which in turn converts to object[] by array covariance. Without this overload a single GeoObjectList argument binds to the "params object[]" constructor in its normal form, so the list is spread into one parameter per contained object instead of being passed as one parameter. Undo would then look for a method taking n objects, not find it and silently do nothing - which broke undo for every operation on more than one object.

public ReversibleChange(object objectToChange, string methodOrPropertyName, GeoObjectList parameter)

Parameters

objectToChange object

The object which will be or was changed

methodOrPropertyName string

the case sensitive name of the method or property

parameter GeoObjectList

the list to pass as a single parameter

ReversibleChange(object, string, object)

public ReversibleChange(object objectToChange, string methodOrPropertyName, object parameter)

Parameters

objectToChange object
methodOrPropertyName string
parameter object

ReversibleChange(object, string, params object[])

Creates a ReversibleChange object. MethodOrPropertyName must be the name (casesensitive!) of a public method or property that reverses the change when called with the parameters given in the parameter "Parameter". If parameters contains exactly 1 object, the Undo method will first look for a set-property with that type to reverse the change. If there is no set-property with that name and type then the system will look for a method with this single parameter.

public ReversibleChange(object objectToChange, string methodOrPropertyName, params object[] parameters)

Parameters

objectToChange object

The object which will be or was changed

methodOrPropertyName string

the case sensitive name of the method or property

parameters object[]

The parameters neede to call this method or property

ReversibleChange(object, Type, string, params object[])

Creates a ReversibleChange object. MethodOrPropertyName must be the name (casesensitive!) of a public method or property that reverses the change when called with the parameters given in the parameter "Parameter". If parameters contains exactly 1 object, the Undo method will first look for a set-property with that type to reverse the change. If there is no set-property with that name and type then the system will look for a method with this single parameter.

public ReversibleChange(object objectToChange, Type interfaceForMethod, string methodOrPropertyName, params object[] parameters)

Parameters

objectToChange object

The object which will be or was changed

interfaceForMethod Type

the interface on which contains the method or property

methodOrPropertyName string

the case sensitive name of the method or property

parameters object[]

The parameters neede to call this method or property

Properties

MethodOrPropertyName

Gets the method or property name for this ReversibleChange

public string MethodOrPropertyName { get; }

Property Value

string

ObjectToChange

Gets the objects which is changed by this ReversibleChange

public object ObjectToChange { get; }

Property Value

object

Parameters

Gets the parameters, that can be used in the method call of this ReversibleChange

public object[] Parameters { get; }

Property Value

object[]

Methods

IsMethod(string)

Checks whether this ReversibleChange ist a method with the given name

public bool IsMethod(string methodName)

Parameters

methodName string

The name of the method

Returns

bool

true, if methodName is the name of the ReversibleChange method

ToString()

Overrides objec.ToString()

public override string ToString()

Returns

string

the call for the undo as a string

Undo()

public bool Undo()

Returns

bool