Click or drag to resize
ActionBuilder Class
Provides UI and project management services for an update action.
Inheritance Hierarchy
SystemObject
  Kjs.AppLife.Update.Engine.Core.DesignActionBuilder

Namespace: Kjs.AppLife.Update.Engine.Core.Design
Assembly: Kjs.AppLife.Update.Engine.Core.Design (in Kjs.AppLife.Update.Engine.Core.Design.dll) Version: 1.0.0.12 (4.0.0.0)
Syntax
[SerializableAttribute]
public class ActionBuilder

The ActionBuilder type exposes the following members.

Constructors
  NameDescription
Public methodActionBuilder
Initializes a new instance of the ActionBuilder class.
Top
Methods
  NameDescription
Public methodCleanupAfterBuild
Performs any work needed after building the project.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitialize
Prepares the builder to work with an action.
Protected methodInitializeExistingAction
Initializes the ActionBuilder and its action after Action has been set to an action that has been loaded.
Protected methodInitializeNewAction
Initializes the ActionBuilder and its action after Action has been set to a newly created action.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnActionChanged
Raises the ActionChanged event.
Protected methodOnDescriptionChanged
Raises the DescriptionChanged event.
Protected methodOnDisplayTextChanged
Raises the DisplayTextChanged event.
Protected methodOnImageChanged
Raises the ImageChanged event.
Protected methodOnIsValidChanged
Raises the IsValidChanged event.
Protected methodOnValidationErrorsChanged
Raises the ValidationErrorsChanged event.
Public methodPrepareForBuild
Performs any work needed to prepare Action for building.
Public methodSetActionDirty
Raises the ActionChanged event, causing the action to be considered dirty, or changed, by the project it belongs to.
Public methodCode exampleStartEditingAction
Starts editing the builder's action.
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
Public methodValidateAction
Checks the state of Action to ensure that it is valid.
Protected methodValidateActionCore
Performs the work of checking the state of Action to ensure that it is valid.
Top
Properties
  NameDescription
Public propertyAction
Gets the UpdateAction associated with the builder.
Public propertyDescription
Gets or sets a description of the action.
Public propertyDisplayText
Gets or sets the text used to represent the builder's Action to the user when Description is blank.
Public propertyImage
Gets or sets the image used to represent the builder's Action to the user.
Public propertyIsValid
Gets a value indicating whether the builder's Action is valid.
Public propertyValidationErrors
Gets a ValidationErrorCollection containing any validation errors for the action.
Top
Events
  NameDescription
Public eventActionChanged
Occurs when Action's data changes.
Public eventDescriptionChanged
Occurs when the Description property value changes.
Public eventDisplayTextChanged
Occurs when the DisplayText property value changes.
Public eventImageChanged
Occurs when the Image property value changes.
Public eventIsValidChanged
Occurs when the IsValid property value changes.
Public eventValidationErrorsChanged
Occurs when the contents of the ValidationErrors property value changes.
Top
Remarks

An ActionBuilder can provide the following for an UpdateAction:

  • A custom editor.
  • Validation that is performed before an update is built.
  • Pre- and post-build actions that can extend the capabilities of an action by, for example, copying files to be included in an update.
  • Initialization after creation or loading.
  • Customizion of the action's appearance to the user.

To create a custom ActionBuilder, inherit from this class and provide a public parameterless constructor. To link an ActionBuilder to an UpdateAction, provide an ActionBuilderAttribute on the UpdateAction, specifying the type of the ActionBuilder. If the type specified in the ActionBuilderAttribute cannot be found, does not inherit from ActionBuilder, or does not have a public, parameterless constructor, the default ActionBuilder will be used instead.

To specify a custom editor, override the StartEditingAction(IServiceProvider) method and use the provided IServiceProvider to to present your custom editor. Note that any custom action editor must ensure that SetActionDirty and ValidateAction are called as needed.

To provide validation for an action, override ValidateActionCore(ValidationErrorCollection) and add any validation errors to the provided collection.

To provide initialization, override InitializeNewAction to initialize newly created actions and InitializeExistingAction to initialize loaded actions.

To customize the action's appearance, set the DisplayText and Image properties.

Examples
An action and its associated builder:
using Kjs.AppLife.Update.Engine.Core;
using Kjs.AppLife.Update.Engine.Core.Design;

[ActionBuilder(typeof(DelayActionBuilder))]
public class DelayAction : UpdateAction {
    private int mSeconds;

    public DelayAction() { }

    public int Seconds {
        get { return this.mSeconds; }
        set { this.mSeconds = value; }
    }

    public override void Execute(UpdateContext context) {
        System.Threading.Thread.Sleep(mSeconds * 1000);
    }

    public override void RollbackExecute(UpdateContext context) { }
}

public class DelayActionBuilder : ActionBuilder {
    public DelayActionBuilder() { }

    private new DelayAction Action {
        get { return (DelayAction)base.Action; }
    }

    protected override void ValidateActionCore(ValidationErrorCollection errors) {
        if(this.Action.Seconds < 0) {
            errors.AddError("Seconds cannot be less than 0.");
        }
    }
}
See Also