Click or drag to resize
UpdateAction Class
Provides the base implementation for all actions that are performed in an AppLife Update action list update.
Inheritance Hierarchy
SystemObject
  Kjs.AppLife.Update.Engine.CoreUpdateAction

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

The UpdateAction type exposes the following members.

Constructors
  NameDescription
Protected methodUpdateAction
Initializes a new instance of the UpdateAction class.
Top
Methods
  NameDescription
Public methodCleanup
Performs any cleanup work needed by the UpdateAction after the target application has been completely updated.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodExecute
Executes the UpdateAction, updating the target application.
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.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnProgressChanged
Raises the ProgressChanged event.
Public methodPrepare
Prepares the target application, performing any tasks needed before Execute(UpdateContext) can be called.
Public methodRollbackExecute
Rolls back any work performed in Execute(UpdateContext).
Public methodRollbackPrepare
Rolls back any work performed in Prepare(UpdateContext).
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
Top
Events
Remarks

To create a custom action, inherit from UpdateAction, provide a public parameterless constructor and implementations for Execute(UpdateContext) and RollbackExecute(UpdateContext).

For storage in projects and in update packages, actions are serialized using an XmlSerializer. In general, public read-write properties and fields will be automatically serialized. See the XmlSerializer documentation for more information on serialization.

When an update is performed, the following steps are taken in order:

  1. All actions are deserialized.
  2. Prepare(UpdateContext) is called on every action in order.
  3. Execute(UpdateContext) is called on every action in order.
  4. Cleanup(UpdateContext) is called on every action in order.

If any error occurs when calling Prepare(UpdateContext), RollbackPrepare(UpdateContext) is called on all actions that completed Prepare(UpdateContext) in reverse order.

If any error occurs when calling Execute(UpdateContext), RollbackExecute(UpdateContext) is called on all actions that completed Execute(UpdateContext) in reverse order, then RollbackPrepare(UpdateContext) is called on all actions in reverse order.

Errors in Cleanup(UpdateContext) are ignored.

Execute(UpdateContext) should contain the primary task performed by the action, and RollbackExecute(UpdateContext) should reverse the effect of that task.

Prepare(UpdateContext) should contain any preparation that needs to be performed before any actions execute, and can throw an exception to abort the update before any changes are made. RollbackPrepare(UpdateContext) should reverse the effect of Prepare(UpdateContext).

Cleanup(UpdateContext) should perform nonessential cleanup that cannot be performed until the update has succeeded.

All five of these methods can optionally call OnProgressChanged(UpdateProgressChangedEventArgs) to report progress from 0 to 100 percent. If no progress events are raised in this way, AppLife Update will automatically report 100% progress for each method when it returns.

Custom actions will appear in the action palette automatically when an assembly that they reside in is added in the AppLife update creation application. The default editor for custom actions uses a PropertyGrid and so only public read-write properties can be edited. To use a custom editor for an action, provide an ActionBuilderAttribute on the action and specify the type of ActionBuilder to use. An ActionBuilder can also perform work when building the update package (such as copying files to go with the update) and customize the action's appearance in the action list.

To customize an action's appearance in the action palette, you can provide an ActionPaletteItemAttribute on the action and specify the type of ActionPaletteItem to use. Alternatively, you can specify one or more of the following attributes on the action, which will be automatically used by the default ActionPaletteItem:

AttributeEffect
DisplayNameAttributeSpecifies the name of the action as it will appear in the palette. Unless a different name is specified by an ActionBuilder, this name will also be used in the action list
CategoryAttributeSpecifies the palette category of the action.
DescriptionAttributeSpecifies the action's tooltip in the palette.
ToolboxBitmapAttributeSpecifies the image that will be used for the action in the palette. Unless a different image is specified by an ActionBuilder, this image will also be used in the action list.
To prevent an action from appearing in the palette, provide an ActionPaletteItemAttribute, specifying in its constructor.

Examples
An action with two properties:
using Kjs.AppLife.Update.Engine.Core;

public class MyAction : UpdateAction {
     private int mNumber;
     private string mText;

     public MyAction() { }

     public int Number {
       get { return mNumber; }
       set { mNumber = value; }
     }

     public string Text {
       get { return mText; }
       set { mText = value; }
     }

     public override void Execute(UpdateContext context) {
       return;
     }

     public override void RollbackExecute(UpdateContext context) {
       return;
     }
}
An action with a customized display name:
using Kjs.AppLife.Update.Engine.Core;

[System.ComponentModel.DisplayName("My other action")]
public class MyOtherAction : UpdateAction {
     public MyOtherAction() { }

     public override void Execute(UpdateContext context) {
       return;
     }

     public override void RollbackExecute(UpdateContext context) {
       return;
     }
}
See Also