Show / Hide Table of Contents

Class Transformation

Class that abstractly implements ITransformation and is intended to provide the grounding for describing the actions to be executed on IEntity objects in order to find a solution to a puzzle. It is recommended that custom transformation descriptors inherit from this class.

Inheritance
System.Object
Transformation
EchoTransformation
StandaloneTransformation
Implements
ITransformation
Namespace: TreeProblemFramework.Description.Transformations

Constructors

Transformation(String)

Initializes a new instance of the Transformation class with the specified title.

Declaration
protected Transformation(string title)
Parameters
Type Name Description
System.String title

The transformation title which, although not mandatory, should be unique among other ITransformation objects related to a puzzle.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if the provided transformation title is either null, empty or white space.

Properties

Title

Gets the title of the current transformation.

Declaration
public string Title { get; }
Property Value
Type Description
System.String

The transformation title.

Methods

Apply(EntityCollection, IEnvironment)

Method that executes the actions to modify the properties or behavior of the specified IEntity objects based on the specified IEnvironment object.

Declaration
protected abstract IEnumerable<IEnvironment> Apply(EntityCollection targetEntities, IEnvironment env)
Parameters
Type Name Description
EntityCollection targetEntities

The collection of IEntity objects whose properties are meant to be mutated or modified.

IEnvironment env

The current IEnvironment object (the current state of the puzzle).

Returns
Type Description
System.Collections.Generic.IEnumerable<IEnvironment>

An enumerator of TransformationResult objects, each of which contains the results of executing the current transformation.

Run(EntityCollection, IEnvironment)

Method that checks whether the actions defined for the current transformation are to be executed on the specified IEntity objects based on the specified IEnvironment object; and only if so, does it execute the actions.

Declaration
public IEnumerable<TransformationResult> Run(EntityCollection targetEntities, IEnvironment env)
Parameters
Type Name Description
EntityCollection targetEntities

The collection of IEntity objects whose properties are meant to be mutated or modified.

IEnvironment env

The current IEnvironment object (the current state of the puzzle).

Returns
Type Description
System.Collections.Generic.IEnumerable<TransformationResult>

An enumerator of TransformationResult objects, each of which contains the results of executing the current transformation.

Validate(EntityCollection, IEnvironment)

Method that checks whether the actions defined for the current transformation are to be executed on the specified IEntity objects based on the specified IEnvironment object.

Declaration
protected abstract bool Validate(EntityCollection targetEntities, IEnvironment env)
Parameters
Type Name Description
EntityCollection targetEntities

The collection of IEntity objects to check whether their properties are meant to be mutated or modified.

IEnvironment env

The current IEnvironment object (the current state of the puzzle).

Returns
Type Description
System.Boolean

True if the actions defined for the current transformation are to be executed on the specified IEntity objects. False they are not.

Implements

ITransformation
Back to top TreeProblemFramework from Ecuador.